X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FClass.pm;h=8668990150cabb7b8026c742e367357e0b5102f8;hp=90331ad542dbc5b71577f61be56701c67582b2ca;hb=47b5feb98e9b293834e412f31cbf88f8f2e3de92;hpb=ad958001acda8f0903f6f6f6deac9d5c0b2fb90f diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 90331ad..8668990 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -63,6 +63,7 @@ sub add_method { my $pkg = $self->name; no strict 'refs'; + no warnings 'redefine'; $self->{'methods'}->{$name}++; # Moose stores meta object here. *{ $pkg . '::' . $name } = $code; } @@ -208,12 +209,7 @@ sub does_role { } sub create { - my ( $class, @args ) = @_; - - unshift @args, 'package' if @args % 2 == 1; - - my (%options) = @args; - my $package_name = $options{package}; + my ($self, $package_name, %options) = @_; (ref $options{superclasses} eq 'ARRAY') || confess "You must pass an ARRAY ref of superclasses" @@ -228,9 +224,6 @@ sub create { if exists $options{methods}; do { - # XXX should I implement Mouse::Meta::Module? - my $package_name = $options{package}; - ( defined $package_name && $package_name ) || confess "You must pass a package name"; @@ -244,7 +237,7 @@ sub create { confess "creation of $package_name failed : $@" if $@; }; - my (%initialize_options) = @args; + my %initialize_options = %options; delete @initialize_options{qw( package superclasses @@ -253,11 +246,11 @@ sub create { version authority )}; - my $meta = $class->initialize( $package_name => %initialize_options ); + my $meta = $self->initialize( $package_name => %initialize_options ); # FIXME totally lame $meta->add_method('meta' => sub { - $class->initialize(ref($_[0]) || $_[0]); + $self->initialize(ref($_[0]) || $_[0]); }); $meta->superclasses(@{$options{superclasses}}) @@ -332,7 +325,7 @@ this class and its superclasses. Returns a mapping of attribute names to their corresponding L objects. -=head2 has_attribute Name -> Boool +=head2 has_attribute Name -> Bool Returns whether we have a L with the given name.