From: Yuval Kogman Date: Sat, 16 Aug 2008 03:38:58 +0000 (+0000) Subject: remove %METAS lexical from Moose::Role, Class::MOP handles registry now X-Git-Tag: 0_55_01~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0474f1d009b070c28c4690a9839cdd6054aa303b;p=gitmo%2FMoose.git remove %METAS lexical from Moose::Role, Class::MOP handles registry now --- diff --git a/lib/Moose/Role.pm b/lib/Moose/Role.pm index cbf9f49..c1ba222 100644 --- a/lib/Moose/Role.pm +++ b/lib/Moose/Role.pm @@ -117,37 +117,32 @@ my $exporter = Moose::Exporter->setup_import_methods( ], ); -{ - my %METAS; +sub init_meta { + shift; + my %args = @_; - sub init_meta { - shift; - my %args = @_; + my $role = $args{for_class} + or confess + "Cannot call init_meta without specifying a for_class"; - my $role = $args{for_class} - or confess - "Cannot call init_meta without specifying a for_class"; + my $metaclass = $args{metaclass} || "Moose::Meta::Role"; - return $METAS{$role} if exists $METAS{$role}; + # make a subtype for each Moose class + role_type $role unless find_type_constraint($role); - my $metaclass = $args{metaclass} || "Moose::Meta::Role"; - - # make a subtype for each Moose class - role_type $role unless find_type_constraint($role); - - my $meta; - if ($role->can('meta')) { - $meta = $role->meta(); - (blessed($meta) && $meta->isa('Moose::Meta::Role')) - || confess "You already have a &meta function, but it does not return a Moose::Meta::Role"; - } - else { - $meta = $metaclass->initialize($role); - $meta->alias_method('meta' => sub { $meta }); - } - - return $METAS{$role} = $meta; + # FIXME copy from Moose.pm + my $meta; + if ($role->can('meta')) { + $meta = $role->meta(); + (blessed($meta) && $meta->isa('Moose::Meta::Role')) + || confess "You already have a &meta function, but it does not return a Moose::Meta::Role"; } + else { + $meta = $metaclass->initialize($role); + $meta->alias_method('meta' => sub { $meta }); + } + + return $meta; } 1;