fix synopsis
[gitmo/MooseX-MetaDescription.git] / lib / MooseX / MetaDescription.pm
CommitLineData
c13295c8 1package MooseX::MetaDescription;
2use Moose;
3
91297cb4 4our $VERSION = '0.01';
5our $AUTHORITY = 'cpan:STEVAN';
6
c13295c8 7use MooseX::MetaDescription::Meta::Class;
8use MooseX::MetaDescription::Meta::Attribute;
5d49532a 9use MooseX::MetaDescription::Description;
c13295c8 10
c13295c8 11no Moose; 1;
12
13__END__
14
15=pod
16
17=head1 NAME
18
48b1f986 19MooseX::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
8055bceb 48 $bar->description; # { node_type => 'element' }
c6936f01 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 58MooseX::MetaDescription allows you to add arbitrary out of band
59metadata to your Moose classes and attributes. This will allow
60you to track out of band data along with attributes, which is
61very 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
73All complex software has bugs lurking in it, and this module is no
74exception. If you find a bug please either email me, or add the bug
75to cpan-RT.
76
77=head1 AUTHOR
78
48b1f986 79Code and Design originally by Jonathan Rockway in the Ernst module,
80extracted and refactored by:
81
c13295c8 82Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
83
84=head1 COPYRIGHT AND LICENSE
85
86Copyright 2008 Infinity Interactive, Inc.
87
88L<http://www.iinteractive.com>
89
90This library is free software; you can redistribute it and/or modify
91it under the same terms as Perl itself.
92
93=cut