X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FModule.pm;h=68329428882d3486dc79674fdfbcb1a9afe66b26;hb=5d10c516c73e34da6e350bc567aaf8c272428c9b;hp=74804c3d30ad88bdbbd60f01e207d5ec622a7469;hpb=c808e3d5c3b5fa953d6b9a3ee7ce4cd2b7925f6c;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Module.pm b/lib/Class/MOP/Module.pm index 74804c3..6832942 100644 --- a/lib/Class/MOP/Module.pm +++ b/lib/Class/MOP/Module.pm @@ -4,9 +4,10 @@ package Class::MOP::Module; use strict; use warnings; +use Carp 'confess'; use Scalar::Util 'blessed'; -our $VERSION = '0.67'; +our $VERSION = '0.76'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -31,6 +32,26 @@ sub identifier { ); } +sub create { + my ( $class, %options ) = @_; + + my $package_name = $options{package}; + + (defined $package_name && $package_name) + || confess "You must pass a package 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}; + + eval $code; + confess "creation of $package_name failed : $@" if $@; + + return; # XXX: should this return some kind of meta object? ~sartak +} + 1; __END__ @@ -47,6 +68,10 @@ This is an abstraction of a Perl 5 module, it is a superclass of L. A module essentially a package with metadata, in our case the version and authority. +=head1 INHERITANCE + +B is a subclass of L + =head1 METHODS =over 4 @@ -74,6 +99,10 @@ package for the given instance. This constructs a string of the name, version and authority. +=item B + +This creates the module; it does not return a useful result. + =back =head1 AUTHORS