From: Shawn M Moore Date: Mon, 22 Dec 2008 04:10:07 +0000 (+0000) Subject: Begin stealing more Moose meta API X-Git-Tag: 0.19~79 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1a72f15c46ec908587e38d2d606ece4f180e2595;p=gitmo%2FMouse.git Begin stealing more Moose meta API --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 90331ad..8d82928 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -208,12 +208,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 +223,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,8 +236,7 @@ sub create { confess "creation of $package_name failed : $@" if $@; }; - my (%initialize_options) = @args; - delete @initialize_options{qw( + delete @options{qw( package superclasses attributes @@ -253,11 +244,11 @@ sub create { version authority )}; - my $meta = $class->initialize( $package_name => %initialize_options ); + my $meta = $self->initialize( $package_name => %options ); # FIXME totally lame $meta->add_method('meta' => sub { - $class->initialize(ref($_[0]) || $_[0]); + $self->initialize(ref($_[0]) || $_[0]); }); $meta->superclasses(@{$options{superclasses}}) diff --git a/t/800_shikabased/008-create_class.t b/t/800_shikabased/008-create_class.t index 1566d90..3d8dcc3 100644 --- a/t/800_shikabased/008-create_class.t +++ b/t/800_shikabased/008-create_class.t @@ -38,7 +38,7 @@ is FooBar->meta->name, "FooBar"; isa_ok( Mouse::Meta::Class->create( - package => "Baz", + "Baz", superclasses => [ "FooBar", "Mouse::Object" ], attributes => [ Mouse::Meta::Attribute->new(