bump version to 0.88
[gitmo/Class-MOP.git] / lib / Class / MOP / Module.pm
CommitLineData
2243a22b 1
2package Class::MOP::Module;
3
4use strict;
5use warnings;
6
4edd0667 7use Carp 'confess';
2243a22b 8use Scalar::Util 'blessed';
9
b7e04496 10our $VERSION = '0.88';
d519662a 11$VERSION = eval $VERSION;
f0480c45 12our $AUTHORITY = 'cpan:STEVAN';
2243a22b 13
14use base 'Class::MOP::Package';
15
7f436b8c 16sub version {
17 my $self = shift;
8b49a472 18 ${$self->get_package_symbol({ sigil => '$', type => 'SCALAR', name => 'VERSION' })};
7f436b8c 19}
20
f0480c45 21sub authority {
22 my $self = shift;
8b49a472 23 ${$self->get_package_symbol({ sigil => '$', type => 'SCALAR', name => 'AUTHORITY' })};
f0480c45 24}
9d6dce77 25
f0480c45 26sub identifier {
27 my $self = shift;
28 join '-' => (
29 $self->name,
30 ($self->version || ()),
31 ($self->authority || ()),
32 );
33}
9d6dce77 34
4edd0667 35sub create {
89f66023 36 confess "The Class::MOP::Module->create method has been made a private object method.\n";
37}
4edd0667 38
89f66023 39sub _instantiate_module {
40 my $self = shift;
41 my $version = shift;
42 my $authority = shift;
4edd0667 43
89f66023 44 my $package_name = $self->name;
4edd0667 45
46 my $code = "package $package_name;";
89f66023 47
48 $code .= "\$$package_name\:\:VERSION = '" . $version . "';"
49 if defined $version;
50 $code .= "\$$package_name\:\:AUTHORITY = '" . $authority . "';"
51 if defined $authority;
4edd0667 52
e4da508a 53 my $e = do {
54 local $@;
55 local $SIG{__DIE__};
56 eval $code;
57 $@;
58 };
59 confess "creation of $package_name failed : $e" if $e;
4edd0667 60}
61
2243a22b 621;
63
64__END__
65
66=pod
67
68=head1 NAME
69
70Class::MOP::Module - Module Meta Object
71
2243a22b 72=head1 DESCRIPTION
73
1f44239e 74A module is essentially a L<Class::MOP::Package> with metadata, in our
75case the version and authority.
127d39a7 76
121991f6 77=head1 INHERITANCE
78
1f44239e 79B<Class::MOP::Module> is a subclass of L<Class::MOP::Package>.
121991f6 80
2243a22b 81=head1 METHODS
82
83=over 4
84
1f44239e 85=item B<< $metamodule->version >>
2243a22b 86
1f44239e 87This is a read-only attribute which returns the C<$VERSION> of the
88package, if one exists.
127d39a7 89
1f44239e 90=item B<< $metamodule->authority >>
127d39a7 91
1f44239e 92This is a read-only attribute which returns the C<$AUTHORITY> of the
93package, if one exists.
127d39a7 94
1f44239e 95=item B<< $metamodule->identifier >>
7f436b8c 96
1f44239e 97This constructs a string which combines the name, version and
98authority.
b9d9fc0b 99
929e9565 100=item B<< Class::MOP::Module->meta >>
f0480c45 101
1f44239e 102This will return a L<Class::MOP::Class> instance for this class.
4edd0667 103
2243a22b 104=back
105
1a09d9cc 106=head1 AUTHORS
2243a22b 107
108Stevan Little E<lt>stevan@iinteractive.comE<gt>
109
110=head1 COPYRIGHT AND LICENSE
111
070bb6c9 112Copyright 2006-2009 by Infinity Interactive, Inc.
2243a22b 113
114L<http://www.iinteractive.com>
115
116This library is free software; you can redistribute it and/or modify
117it under the same terms as Perl itself.
118
ebce5539 119=cut