X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FClassData.pm;h=6174ffd7a6475a35299d852e1c13b4a238467152;hb=8be895a7aa1d89a8004cc0cd37962025bc5c3b3d;hp=154062a53c2d6d8980f2ebd1c3402d7c27d13e29;hpb=eece41a2b27bdca624a6025d8a6055135e655e52;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/ClassData.pm b/lib/Catalyst/ClassData.pm index 154062a..6174ffd 100644 --- a/lib/Catalyst/ClassData.pm +++ b/lib/Catalyst/ClassData.pm @@ -2,6 +2,7 @@ package Catalyst::ClassData; use Moose::Role; use Class::MOP; +use Class::MOP::Object; use Scalar::Util 'blessed'; sub mk_classdata { @@ -11,9 +12,9 @@ sub mk_classdata { my $slot = '$'.$attribute; my $accessor = sub { - my $meta = $_[0]->meta; my $pkg = ref $_[0] || $_[0]; - if(@_ > 1){ + my $meta = $pkg->Class::MOP::Object::meta(); + if (@_ > 1) { $meta->namespace->{$attribute} = \$_[1]; return $_[1]; } @@ -30,7 +31,7 @@ sub mk_classdata { foreach my $super ( $meta->linearized_isa ) { # tighter version of same after # my $super_meta = Moose::Meta::Class->initialize($super); - my $v = *{"${super}::${attribute}"}{SCALAR}; + my $v = ${"${super}::"}{$attribute} ? *{"${super}::${attribute}"}{SCALAR} : undef; if (defined ${$v}) { return ${$v}; } @@ -42,7 +43,7 @@ sub mk_classdata { confess("Failed to create accessor: $@ ") unless ref $accessor eq 'CODE'; - my $meta = $class->meta; + my $meta = $class->Class::MOP::Object::meta(); my $immutable_options; if( $meta->is_immutable ){ $immutable_options = $meta->get_immutable_options; @@ -52,7 +53,7 @@ sub mk_classdata { $meta->add_method($alias, $accessor); $meta->add_method($attribute, $accessor); if(defined $immutable_options){ - $meta->make_immutable($immutable_options); + $meta->make_immutable(%{ $immutable_options }); } $class->$attribute($_[2]) if(@_ > 2); return $accessor;