Commit | Line | Data |
2243a22b |
1 | |
2 | package Class::MOP::Module; |
3 | |
4 | use strict; |
5 | use warnings; |
6 | |
7 | use Scalar::Util 'blessed'; |
8 | |
9d6dce77 |
9 | our $VERSION = '0.02'; |
f0480c45 |
10 | our $AUTHORITY = 'cpan:STEVAN'; |
2243a22b |
11 | |
12 | use base 'Class::MOP::Package'; |
13 | |
14 | # introspection |
15 | |
16 | sub meta { |
17 | require Class::MOP::Class; |
18 | Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); |
19 | } |
20 | |
7f436b8c |
21 | sub version { |
22 | my $self = shift; |
58d75218 |
23 | ${$self->get_package_symbol('$VERSION')}; |
7f436b8c |
24 | } |
25 | |
f0480c45 |
26 | sub authority { |
27 | my $self = shift; |
28 | ${$self->get_package_symbol('$AUTHORITY')}; |
29 | } |
9d6dce77 |
30 | |
f0480c45 |
31 | sub identifier { |
32 | my $self = shift; |
33 | join '-' => ( |
34 | $self->name, |
35 | ($self->version || ()), |
36 | ($self->authority || ()), |
37 | ); |
38 | } |
9d6dce77 |
39 | |
2243a22b |
40 | 1; |
41 | |
42 | __END__ |
43 | |
44 | =pod |
45 | |
46 | =head1 NAME |
47 | |
48 | Class::MOP::Module - Module Meta Object |
49 | |
2243a22b |
50 | =head1 DESCRIPTION |
51 | |
127d39a7 |
52 | This is an abstraction of a Perl 5 module, it is a superclass of |
53 | L<Class::MOP::Class>. A module essentially a package with metadata, |
54 | in our case the version and authority. |
55 | |
2243a22b |
56 | =head1 METHODS |
57 | |
58 | =over 4 |
59 | |
60 | =item B<meta> |
61 | |
127d39a7 |
62 | Returns a metaclass for this package. |
63 | |
64 | =item B<initialize ($package_name)> |
65 | |
66 | This will initialize a Class::MOP::Module instance which represents |
67 | the module of C<$package_name>. |
68 | |
7f436b8c |
69 | =item B<version> |
70 | |
b9d9fc0b |
71 | This is a read-only attribute which returns the C<$VERSION> of the |
72 | package for the given instance. |
73 | |
f0480c45 |
74 | =item B<authority> |
75 | |
b9d9fc0b |
76 | This is a read-only attribute which returns the C<$AUTHORITY> of the |
77 | package for the given instance. |
78 | |
f0480c45 |
79 | =item B<identifier> |
80 | |
96e38ba6 |
81 | This constructs a string of the name, version and authority. |
b9d9fc0b |
82 | |
2243a22b |
83 | =back |
84 | |
1a09d9cc |
85 | =head1 AUTHORS |
2243a22b |
86 | |
87 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
88 | |
89 | =head1 COPYRIGHT AND LICENSE |
90 | |
69e3ab0a |
91 | Copyright 2006-2008 by Infinity Interactive, Inc. |
2243a22b |
92 | |
93 | L<http://www.iinteractive.com> |
94 | |
95 | This library is free software; you can redistribute it and/or modify |
96 | it under the same terms as Perl itself. |
97 | |
98 | =cut |