From: Dave Rolsky Date: Wed, 6 Aug 2008 16:44:05 +0000 (+0000) Subject: Move init_meta() to the end to match Moose.pm X-Git-Tag: 0_55_01~43^2~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbb03d24a2f835268ff62e898049aea411b82a1c;p=gitmo%2FMoose.git Move init_meta() to the end to match Moose.pm --- diff --git a/lib/Moose/Role.pm b/lib/Moose/Role.pm index 7a29948..98b322c 100644 --- a/lib/Moose/Role.pm +++ b/lib/Moose/Role.pm @@ -19,32 +19,6 @@ use Moose::Util (); use Moose::Meta::Role; use Moose::Util::TypeConstraints; -{ - my %METAS; - - sub init_meta { - my $role = shift; - - return $METAS{$role} if exists $METAS{$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 = Moose::Meta::Role->initialize($role); - $meta->alias_method('meta' => sub { $meta }); - } - - return $METAS{$role} = $meta; - } -} - sub extends { croak "Roles do not currently support 'extends'"; } @@ -174,6 +148,32 @@ sub unimport { ); } +{ + my %METAS; + + sub init_meta { + my $role = shift; + + return $METAS{$role} if exists $METAS{$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 = Moose::Meta::Role->initialize($role); + $meta->alias_method('meta' => sub { $meta }); + } + + return $METAS{$role} = $meta; + } +} + 1; __END__