2 package Class::MOP::Module;
8 use Scalar::Util 'blessed';
10 our $VERSION = '0.94';
11 $VERSION = eval $VERSION;
12 our $AUTHORITY = 'cpan:STEVAN';
14 use base 'Class::MOP::Package';
18 return Class::MOP::Class->initialize($class)->new_object(@_)
19 if $class ne __PACKAGE__;
21 my $params = @_ == 1 ? $_[0] : {@_};
24 # from Class::MOP::Package
25 package => $params->{package},
36 ${$self->get_package_symbol({ sigil => '$', type => 'SCALAR', name => 'VERSION' })};
41 ${$self->get_package_symbol({ sigil => '$', type => 'SCALAR', name => 'AUTHORITY' })};
48 ($self->version || ()),
49 ($self->authority || ()),
54 confess "The Class::MOP::Module->create method has been made a private object method.\n";
57 sub _instantiate_module {
58 my($self, $version, $authority) = @_;
59 my $package_name = $self->name;
61 Class::MOP::_is_valid_class_name($package_name)
62 || confess "creation of $package_name failed: invalid package name";
65 scalar %{ $package_name . '::' }; # touch the stash
66 ${ $package_name . '::VERSION' } = $version if defined $version;
67 ${ $package_name . '::AUTHORITY' } = $authority if defined $authority;
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.
118 Stevan Little E<lt>stevan@iinteractive.comE<gt>
120 =head1 COPYRIGHT AND LICENSE
122 Copyright 2006-2009 by Infinity Interactive, Inc.
124 L<http://www.iinteractive.com>
126 This library is free software; you can redistribute it and/or modify
127 it under the same terms as Perl itself.