X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FModule.pm;h=33eb10a5bdd6a0affb53078a8a8ce0d73fbd3752;hb=b4bd10ecd2eabe1a2c1bc3addad22b207f6592ee;hp=bb5859f9528114f8227849f7e4fd9957a5e7a93e;hpb=d7b2249e7fbce92cc716fea172cf338727478b78;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Module.pm b/lib/Class/MOP/Module.pm index bb5859f..33eb10a 100644 --- a/lib/Class/MOP/Module.pm +++ b/lib/Class/MOP/Module.pm @@ -4,21 +4,23 @@ package Class::MOP::Module; use strict; use warnings; +use Carp 'confess'; use Scalar::Util 'blessed'; -our $VERSION = '0.03'; +our $VERSION = '0.77'; +$VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Package'; sub version { my $self = shift; - ${$self->get_package_symbol('$VERSION')}; + ${$self->get_package_symbol({ sigil => '$', type => 'SCALAR', name => 'VERSION' })}; } sub authority { my $self = shift; - ${$self->get_package_symbol('$AUTHORITY')}; + ${$self->get_package_symbol({ sigil => '$', type => 'SCALAR', name => 'AUTHORITY' })}; } sub identifier { @@ -30,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__ @@ -46,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 @@ -73,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 @@ -88,4 +118,4 @@ L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut