twweaking
[gitmo/MooseX-MetaDescription.git] / lib / MooseX / MetaDescription.pm
1 package MooseX::MetaDescription;
2 use Moose;
3
4 our $VERSION   = '0.01';
5 our $AUTHORITY = 'cpan:STEVAN';
6
7 use MooseX::MetaDescription::Meta::Class;
8 use MooseX::MetaDescription::Meta::Attribute;
9 use MooseX::MetaDescription::Description;
10
11 no Moose; 1;
12
13 __END__
14
15 =pod
16
17 =head1 NAME
18
19 MooseX::MetaDescription - A framework for adding additional metadata to Moose classes
20
21 =head1 SYNOPSIS
22
23     package Foo;
24     use metaclass 'MooseX::MetaDescription::Meta::Class';
25     use Moose;
26     
27     # add class-level metadata
28     __PACKAGE__->meta->description->{'Hello'} = 'World';
29
30     has 'bar' => (
31         metaclass   => 'MooseX::MetaDescription::Meta::Attribute',
32         is          => 'ro',
33         isa         => 'Str',   
34         default     => sub { Bar->new() },
35         # add attribute level metadata
36         description => {
37             node_type   => 'element',
38         }
39     );
40
41     ...
42     
43     $foo->meta->description; # { 'Hello' => 'World' }
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;
55
56 =head1 DESCRIPTION
57
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.
62
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
79 Code and Design originally by Jonathan Rockway in the Ernst module, 
80 extracted and refactored by:
81
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