# Creation
sub initialize {
- my $class = shift;
- my $package_name = shift;
+ my ( $class, @args ) = @_;
+
+ unshift @args, 'package' if @args % 2 == 1;
+
+ my (%options) = @args;
+ my $package_name = $options{package};
+
(defined $package_name && $package_name && !blessed($package_name))
|| confess "You must pass a package name and it cannot be blessed";
+
return Class::MOP::get_metaclass_by_name($package_name)
- || $class->construct_class_instance('package' => $package_name, @_);
+ || $class->construct_class_instance(%options);
}
sub reinitialize {
sub create {
my ( $class, @args ) = @_;
- unshift @args, 'name' if @args % 2 == 1;
+ unshift @args, 'package' if @args % 2 == 1;
my (%options) = @args;
- my $package_name = $options{name};
+ my $package_name = $options{package};
(defined $package_name && $package_name)
|| confess "You must pass a package name";
# ... test our class creator
my $Bar = Class::MOP::Class->create(
- name => 'Bar',
+ package => 'Bar',
superclasses => [ 'Foo' ],
methods => {
foo => sub { 'Bar::foo' },