From: Tomas Doran Date: Wed, 7 Jan 2009 23:24:56 +0000 (+0000) Subject: Use the appropriate MOP function to be a bit neater and more 'correct' X-Git-Tag: 5.8000_05~41 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=e106a59f5b94228aa1df4cf2224e06c5ef53298b Use the appropriate MOP function to be a bit neater and more 'correct' --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 3471a6c..aafee0b 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -5,7 +5,6 @@ package Catalyst; use Class::C3; use Moose; -use Class::MOP::Object (); extends 'Catalyst::Component'; use bytes; use Scope::Upper (); @@ -1033,7 +1032,7 @@ EOF # modifiers work correctly in MyApp (as you have to call setup _before_ # applying modifiers). Scope::Upper::reap(sub { - my $meta = $class->Moose::Object::meta(); + my $meta = Class::MOP::get_metaclass_by_name($class); $meta->make_immutable unless $meta->is_immutable; }, 1); @@ -2102,7 +2101,7 @@ sub setup_engine { } if ( $ENV{MOD_PERL} ) { - my $meta = $class->Class::MOP::Object::meta(); + my $meta = Class::MOP::get_metaclass_by_name($class); # create the apache method $meta->add_method('apache' => sub { shift->engine->apache }); @@ -2252,7 +2251,7 @@ sub setup_log { my $env_debug = Catalyst::Utils::env_value( $class, 'DEBUG' ); if ( defined($env_debug) or $levels{debug} ) { - $class->Class::MOP::Object::meta()->add_method('debug' => sub { 1 }); + Class::MOP::get_metaclass_by_name($class)->add_method('debug' => sub { 1 }); $class->log->debug('Debug messages enabled'); } } @@ -2276,7 +2275,7 @@ sub setup_stats { my $env = Catalyst::Utils::env_value( $class, 'STATS' ); if ( defined($env) ? $env : ($stats || $class->debug ) ) { - $class->Class::MOP::Object::meta()->add_method('use_stats' => sub { 1 }); + Class::MOP::get_metaclass_by_name($class)->add_method('use_stats' => sub { 1 }); $class->log->debug('Statistics enabled'); } } @@ -2319,7 +2318,7 @@ the plugin name does not begin with C. $proto->_plugins->{$plugin} = 1; unless ($instant) { no strict 'refs'; - if ( my $meta = $class->Class::MOP::Object::meta() ) { + if ( my $meta = Class::MOP::get_metaclass_by_name($class) ) { my @superclasses = ($plugin, $meta->superclasses ); $meta->superclasses(@superclasses); } else { diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 1301fc8..13ccb2c 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -7,6 +7,7 @@ use Catalyst::Utils; use Class::C3::Adopt::NEXT; use MRO::Compat; use mro 'c3'; +use Scalar::Util qw/blessed/; with 'MooseX::Emulate::Class::Accessor::Fast'; with 'Catalyst::ClassData'; @@ -99,7 +100,8 @@ sub config { # 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 $meta = $self->Class::MOP::Object::meta(); + my $class = blessed($self) || $self; + my $meta = Class::MOP::get_metaclass_by_name($class); unless ($meta->has_package_symbol('$_config')) { $config = $self->merge_config_hashes( $config, {} ); diff --git a/lib/Catalyst/Log.pm b/lib/Catalyst/Log.pm index a74f614..5557066 100644 --- a/lib/Catalyst/Log.pm +++ b/lib/Catalyst/Log.pm @@ -4,7 +4,7 @@ use Moose; with 'MooseX::Emulate::Class::Accessor::Fast'; use Data::Dump; -use Class::MOP::Object (); +use Class::MOP (); our %LEVELS = (); @@ -15,7 +15,7 @@ has abort => (is => 'rw'); { my @levels = qw[ debug info warn error fatal ]; - my $meta = __PACKAGE__->Class::MOP::Object::meta(); + my $meta = Class::MOP::get_metaclass_by_name(__PACKAGE__); for ( my $i = 0 ; $i < @levels ; $i++ ) { my $name = $levels[$i];