2 package Class::MOP::Module;
8 use Scalar::Util 'blessed';
10 use base 'Class::MOP::Package';
14 return Class::MOP::Class->initialize($class)->new_object(@_)
15 if $class ne __PACKAGE__;
17 my $params = @_ == 1 ? $_[0] : {@_};
19 # Need to quote package to avoid a problem with PPI mis-parsing this
20 # as a package statement.
22 # from Class::MOP::Package
23 'package' => $params->{package},
34 ${$self->get_or_add_package_symbol('$VERSION')};
39 ${$self->get_or_add_package_symbol('$AUTHORITY')};
46 ($self->version || ()),
47 ($self->authority || ()),
55 unshift @args, 'package' if @args % 2 == 1;
58 my $package = delete $options{package};
59 my $version = delete $options{version};
60 my $authority = delete $options{authority};
62 my $meta = $class->SUPER::create($package => %options);
64 $meta->_instantiate_module($version, $authority);
69 sub _anon_package_prefix { 'Class::MOP::Module::__ANON__::SERIAL::' }
70 sub _anon_cache_key { confess "Modules are not cacheable" }
73 sub _instantiate_module {
74 my($self, $version, $authority) = @_;
75 my $package_name = $self->name;
77 $self->add_package_symbol('$VERSION' => $version)
79 $self->add_package_symbol('$AUTHORITY' => $authority)
80 if defined $authority;
87 # ABSTRACT: Module Meta Object
95 A module is essentially a L<Class::MOP::Package> with metadata, in our
96 case the version and authority.
100 B<Class::MOP::Module> is a subclass of L<Class::MOP::Package>.
106 =item B<< Class::MOP::Module->create($package, %options) >>
108 Overrides C<create> from L<Class::MOP::Package> to provide these additional
115 A version number, to be installed in the C<$VERSION> package global variable.
119 An authority, to be installed in the C<$AUTHORITY> package global variable.
123 =item B<< $metamodule->version >>
125 This is a read-only attribute which returns the C<$VERSION> of the
126 package, if one exists.
128 =item B<< $metamodule->authority >>
130 This is a read-only attribute which returns the C<$AUTHORITY> of the
131 package, if one exists.
133 =item B<< $metamodule->identifier >>
135 This constructs a string which combines the name, version and
138 =item B<< Class::MOP::Module->meta >>
140 This will return a L<Class::MOP::Class> instance for this class.