From: Dave Rolsky Date: Tue, 17 Mar 2009 17:12:11 +0000 (-0500) Subject: Rename CMOP::Module->create to _instantiate_module. The create method X-Git-Tag: 0.80_01~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=89f660234af3ea76105ad29862b4092d54b06fcf;p=gitmo%2FClass-MOP.git Rename CMOP::Module->create to _instantiate_module. The create method was totally unrelated to the create method in CMOP::Class, as it doesn't return anything. AFAICT, the only thing that was calling create was CMOP::Class itself. --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 0583911..3592fef 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -277,8 +277,6 @@ sub create { || 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 @@ -290,6 +288,8 @@ sub create { )}; 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]); diff --git a/lib/Class/MOP/Module.pm b/lib/Class/MOP/Module.pm index 8ff573c..a262915 100644 --- a/lib/Class/MOP/Module.pm +++ b/lib/Class/MOP/Module.pm @@ -33,23 +33,25 @@ sub identifier { } 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; diff --git a/t/010_self_introspection.t b/t/010_self_introspection.t index 5ccb59f..9b63ea6 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 252; +use Test::More tests => 254; use Test::Exception; use Class::MOP; @@ -40,6 +40,8 @@ my @class_mop_package_methods = qw( my @class_mop_module_methods = qw( _new + _instantiate_module + version authority identifier create );