|| confess "You must pass a HASH ref of methods"
if exists $options{methods};
- $class->SUPER::create(%options);
-
my (%initialize_options) = @args;
delete @initialize_options{qw(
package
)};
my $meta = $class->initialize( $package_name => %initialize_options );
+ $meta->_instantiate_module( $options{version}, $options{authority} );
+
# FIXME totally lame
$meta->add_method('meta' => sub {
$class->initialize(ref($_[0]) || $_[0]);
}
sub create {
- my ( $class, %options ) = @_;
+ confess "The Class::MOP::Module->create method has been made a private object method.\n";
+}
- my $package_name = $options{package};
+sub _instantiate_module {
+ my $self = shift;
+ my $version = shift;
+ my $authority = shift;
- (defined $package_name && $package_name)
- || confess "You must pass a package name";
+ my $package_name = $self->name;
my $code = "package $package_name;";
- $code .= "\$$package_name\:\:VERSION = '" . $options{version} . "';"
- if exists $options{version};
- $code .= "\$$package_name\:\:AUTHORITY = '" . $options{authority} . "';"
- if exists $options{authority};
+
+ $code .= "\$$package_name\:\:VERSION = '" . $version . "';"
+ if defined $version;
+ $code .= "\$$package_name\:\:AUTHORITY = '" . $authority . "';"
+ if defined $authority;
eval $code;
confess "creation of $package_name failed : $@" if $@;
-
- return; # XXX: should this return some kind of meta object? ~sartak
}
1;
use strict;
use warnings;
-use Test::More tests => 252;
+use Test::More tests => 254;
use Test::Exception;
use Class::MOP;
my @class_mop_module_methods = qw(
_new
+ _instantiate_module
+
version authority identifier create
);