Commit | Line | Data |
c13295c8 |
1 | package MooseX::MetaDescription; |
2 | use Moose; |
3 | |
91297cb4 |
4 | our $VERSION = '0.01'; |
5 | our $AUTHORITY = 'cpan:STEVAN'; |
6 | |
c13295c8 |
7 | use MooseX::MetaDescription::Meta::Class; |
8 | use MooseX::MetaDescription::Meta::Attribute; |
5d49532a |
9 | use MooseX::MetaDescription::Description; |
c13295c8 |
10 | |
c13295c8 |
11 | no Moose; 1; |
12 | |
13 | __END__ |
14 | |
15 | =pod |
16 | |
17 | =head1 NAME |
18 | |
48b1f986 |
19 | MooseX::MetaDescription - A framework for adding additional metadata to Moose classes |
c13295c8 |
20 | |
21 | =head1 SYNOPSIS |
22 | |
17f25b49 |
23 | package Foo; |
c6936f01 |
24 | use metaclass 'MooseX::MetaDescription::Meta::Class'; |
17f25b49 |
25 | use Moose; |
c6936f01 |
26 | |
27 | # add class-level metadata |
28 | __PACKAGE__->meta->description->{'Hello'} = 'World'; |
17f25b49 |
29 | |
17f25b49 |
30 | has 'bar' => ( |
31 | metaclass => 'MooseX::MetaDescription::Meta::Attribute', |
32 | is => 'ro', |
33 | isa => 'Str', |
f2ce52cc |
34 | default => sub { Bar->new() }, |
c6936f01 |
35 | # add attribute level metadata |
17f25b49 |
36 | description => { |
f2ce52cc |
37 | node_type => 'element', |
17f25b49 |
38 | } |
39 | ); |
40 | |
41 | ... |
42 | |
43 | $foo->meta->description; # { 'Hello' => 'World' } |
c6936f01 |
44 | |
45 | my $bar = $foo->meta->get_attribute('bar'); |
46 | |
47 | # access the desciption HASH directly |
48 | $bar->description; # { baz => 'Foo::bar::baz' } |
49 | |
50 | # or access the instance of MooseX::MetaDescription::Description |
51 | $bar->metadescription; |
52 | |
53 | # access the original attribute metaobject from the metadesc too |
54 | $bar->metadescription->descriptor == $bar; |
c13295c8 |
55 | |
56 | =head1 DESCRIPTION |
57 | |
c6936f01 |
58 | MooseX::MetaDescription allows you to add arbitrary out of band |
59 | metadata to your Moose classes and attributes. This will allow |
60 | you to track out of band data along with attributes, which is |
61 | very useful for say serializing Moose classes in HTML or XML. |
0cb2eb0f |
62 | |
c13295c8 |
63 | =head1 METHODS |
64 | |
65 | =over 4 |
66 | |
67 | =item B<> |
68 | |
69 | =back |
70 | |
71 | =head1 BUGS |
72 | |
73 | All complex software has bugs lurking in it, and this module is no |
74 | exception. If you find a bug please either email me, or add the bug |
75 | to cpan-RT. |
76 | |
77 | =head1 AUTHOR |
78 | |
48b1f986 |
79 | Code and Design originally by Jonathan Rockway in the Ernst module, |
80 | extracted and refactored by: |
81 | |
c13295c8 |
82 | Stevan Little E<lt>stevan.little@iinteractive.comE<gt> |
83 | |
84 | =head1 COPYRIGHT AND LICENSE |
85 | |
86 | Copyright 2008 Infinity Interactive, Inc. |
87 | |
88 | L<http://www.iinteractive.com> |
89 | |
90 | This library is free software; you can redistribute it and/or modify |
91 | it under the same terms as Perl itself. |
92 | |
93 | =cut |