[Catalyst-commits] r7993 - in Catalyst-Runtime/5.80/trunk: .
lib/Catalyst
groditi at dev.catalyst.perl.org
groditi at dev.catalyst.perl.org
Mon Jun 23 22:21:16 BST 2008
Author: groditi
Date: 2008-06-23 22:21:16 +0100 (Mon, 23 Jun 2008)
New Revision: 7993
Modified:
Catalyst-Runtime/5.80/trunk/
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm
Log:
r18430 at martha (orig r7908): matthewt | 2008-06-10 12:55:37 -0400
put config() back to old code but with a new copy-up test
Property changes on: Catalyst-Runtime/5.80/trunk
___________________________________________________________________
Name: svk:merge
- 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:7576
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7907
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
+ 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:7576
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7908
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm 2008-06-23 21:21:10 UTC (rev 7992)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm 2008-06-23 21:21:16 UTC (rev 7993)
@@ -55,6 +55,7 @@
=cut
__PACKAGE__->mk_classdata('_plugins');
+__PACKAGE__->mk_classdata('_config');
around new => sub {
my ( $orig, $self) = @_;
@@ -83,39 +84,27 @@
}
sub config {
- my $self = shift;
- my $class = blessed $self || $self;
+ my $self = shift;
+ my $config = $self->_config || {};
+ if (@_) {
+ my $newconfig = { %{@_ > 1 ? {@_} : $_[0]} };
+ $self->_config(
+ $self->merge_config_hashes( $config, $newconfig )
+ );
+ } else {
+ # this is a bit of a kludge, required to make
+ # __PACKAGE__->config->{foo} = 'bar';
+ # work in a subclass. If we don't have the package symbol in the
+ # current class we know we need to copy up to ours, which calling
+ # the setter will do for us.
- my $config;
- my $meta = $class->meta;
- if( $meta->has_package_symbol('$config') ){
- $config = ${ $meta->get_package_symbol('$config') };
- } else {
- foreach my $super ( $meta->linearized_isa ) {
- my $super_meta = Moose::Meta::Class->initialize($super);
- if( $super_meta->has_package_symbol('$config') ){
- $config = ${ $super_meta->get_package_symbol('$config') };
- unless( @_ ){ #don't copy and write it twice
- $config = $class->merge_config_hashes( $config, {} );
- $meta->add_package_symbol('$config', \ $config);
+ unless ($self->meta->has_package_symbol('$_config')) {
+
+ $config = $self->merge_config_hashes( $config, {} );
+ $self->_config( $config );
}
- last;
- }
}
- }
-
- unless( defined $config ){
- $config = {};
- $meta->add_package_symbol('$config', \ $config) unless @_;
- }
-
- if (@_) {
- my $from_args = { %{@_ > 1 ? {@_} : $_[0]} };
- my $new_config = $class->merge_config_hashes( $config, $from_args);
- $meta->add_package_symbol('$config', \ $new_config);
- }
-
- return $config;
+ return $config;
}
sub merge_config_hashes {
More information about the Catalyst-commits
mailing list