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 || ()),
52 confess "The Class::MOP::Module->create method has been made a private object method.\n";
55 sub _instantiate_module {
56 my($self, $version, $authority) = @_;
57 my $package_name = $self->name;
59 Class::MOP::_is_valid_class_name($package_name)
60 || confess "creation of $package_name failed: invalid package name";
63 scalar %{ $package_name . '::' }; # touch the stash
64 ${ $package_name . '::VERSION' } = $version if defined $version;
65 ${ $package_name . '::AUTHORITY' } = $authority if defined $authority;
72 # ABSTRACT: Module Meta Object
80 Class::MOP::Module - Module Meta Object
84 A module is essentially a L<Class::MOP::Package> with metadata, in our
85 case the version and authority.
89 B<Class::MOP::Module> is a subclass of L<Class::MOP::Package>.
95 =item B<< $metamodule->version >>
97 This is a read-only attribute which returns the C<$VERSION> of the
98 package, if one exists.
100 =item B<< $metamodule->authority >>
102 This is a read-only attribute which returns the C<$AUTHORITY> of the
103 package, if one exists.
105 =item B<< $metamodule->identifier >>
107 This constructs a string which combines the name, version and
110 =item B<< Class::MOP::Module->meta >>
112 This will return a L<Class::MOP::Class> instance for this class.