my $pkg = $self->name;
no strict 'refs';
+ no warnings 'redefine';
$self->{'methods'}->{$name}++; # Moose stores meta object here.
*{ $pkg . '::' . $name } = $code;
}
}
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"
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";
confess "creation of $package_name failed : $@" if $@;
};
- my (%initialize_options) = @args;
+ my %initialize_options = %options;
delete @initialize_options{qw(
package
superclasses
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}})
Returns a mapping of attribute names to their corresponding
L<Mouse::Meta::Attribute> objects.
-=head2 has_attribute Name -> Boool
+=head2 has_attribute Name -> Bool
Returns whether we have a L<Mouse::Meta::Attribute> with the given name.