0.02
[gitmo/MooseX-MetaDescription.git] / lib / MooseX / MetaDescription / Meta / Class.pm
CommitLineData
c13295c8 1package MooseX::MetaDescription::Meta::Class;
2use Moose;
3
d9f5e5ae 4our $VERSION = '0.02';
c13295c8 5our $AUTHORITY = 'cpan:STEVAN';
6
7extends 'Moose::Meta::Class';
b70e06c6 8 with 'MooseX::MetaDescription::Meta::Trait';
d9f5e5ae 9
10has '+description' => (
11 default => sub {
12 my $self = shift;
13 my @supers = $self->linearized_isa;
14 shift @supers;
15 my %desc;
16 foreach my $super (@supers) {
17 if ($super->meta->isa('MooseX::MetaDescription::Meta::Class')) {
18 %desc = (%{ $super->meta->description }, %desc)
19 }
20 }
21 \%desc;
22 },
23);
c13295c8 24
25no Moose; 1;
26
27__END__
28
29=pod
30
31=head1 NAME
32
d253607a 33MooseX::MetaDescription::Meta::Class - Custom class metaclass for meta-descriptions
c13295c8 34
56e78a9c 35=head1 SYNOPSIS
36
37 package Foo;
38 use metaclass 'MooseX::MetaDescription::Meta::Class' => (
39 description => {
40 'Hello' => 'World',
41 }
42 );
43 use Moose;
44
45 package Bar;
46 use Moose;
47
48 extends 'Foo';
49
50 # always add it *after* the extends
51 __PACKAGE__->meta->description->{'Hello'} = 'Earth';
52
53 package Baz;
54 use Moose;
55
56 extends 'Bar';
57
58 package Gorch;
59 use metaclass 'MooseX::MetaDescription::Meta::Class' => (
60 description => {
61 'Hello' => 'World'
62 }
63 );
64 use Moose;
65
66 extends 'Baz';
67
68 # ...
69
70 Foo->meta->description # { 'Hello' => 'World', 'World' => 'Hello' }
71 Bar->meta->description # { 'Hello' => 'Earth', 'World' => 'Hello' } # change one, inherit the other
72 Baz->meta->description # { 'Hello' => 'Earth', 'World' => 'Hello' } # inherit both
73 Gorch->meta->description # { 'Hello' => 'World' } # overrides all, no inheritance
74
c13295c8 75=head1 DESCRIPTION
76
56e78a9c 77This module provides the custom metaclass to add Meta Descriptions
78to your classes. It provides a limited degree of inheritance of
79meta-descriptions, the details of which are shown above in the
80SYNOPSIS section.
81
82=head1 METHODS
83
84NOTE: these are methods composed into this class from
85L<MooseX::MetaDescription::Meta::Trait> refer to that
86module for the complete description.
87
88=over 4
89
90=item B<description>
91
92=item B<metadescription_classname>
93
94=item B<metadescription>
95
96=item B<meta>
97
98=back
c13295c8 99
100=head1 BUGS
101
de7ba0e9 102All complex software has bugs lurking in it, and this module is no
c13295c8 103exception. If you find a bug please either email me, or add the bug
104to cpan-RT.
105
106=head1 AUTHOR
107
108Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
109
110=head1 COPYRIGHT AND LICENSE
111
112Copyright 2008 Infinity Interactive, Inc.
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
119=cut