X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FMetaDescription.pm;h=3baa9e0180c6662fde39a9c334f9f573351e5760;hb=d253607a5105ff1624c0e6146184118bfc97f49a;hp=4606763d48405b1dabcc89a2df15f4e2bad7f12b;hpb=f2ce52ccc6ccbcf8a2009c5ba5c4f5d3067bc2a3;p=gitmo%2FMooseX-MetaDescription.git diff --git a/lib/MooseX/MetaDescription.pm b/lib/MooseX/MetaDescription.pm index 4606763..3baa9e0 100644 --- a/lib/MooseX/MetaDescription.pm +++ b/lib/MooseX/MetaDescription.pm @@ -21,35 +21,44 @@ MooseX::MetaDescription - A framework for adding additional metadata to Moose cl =head1 SYNOPSIS package Foo; + use metaclass 'MooseX::MetaDescription::Meta::Class'; use Moose; + + # add class-level metadata + __PACKAGE__->meta->description->{'Hello'} = 'World'; has 'bar' => ( metaclass => 'MooseX::MetaDescription::Meta::Attribute', is => 'ro', isa => 'Str', default => sub { Bar->new() }, + # add attribute level metadata description => { node_type => 'element', } ); - ... + my $foo = Foo->new; $foo->meta->description; # { 'Hello' => 'World' } - $foo->meta->get_attribute('bar')->description; # { baz => 'Foo::bar::baz' } + + my $bar = $foo->meta->get_attribute('bar'); + + # access the desciption HASH directly + $bar->description; # { node_type => 'element' } + + # or access the instance of MooseX::MetaDescription::Description + $bar->metadescription; + + # access the original attribute metaobject from the metadesc too + $bar->metadescription->descriptor == $bar; =head1 DESCRIPTION -MooseX::MetaDescription allows you to add arbitrary out of band metadata to your Moose classes and attributes. This will allow you to -track out of band data along with attributes, which is very useful for say serializing Moose classes in HTML or XML. - -=head1 METHODS - -=over 4 - -=item B<> - -=back +MooseX::MetaDescription allows you to add arbitrary out of band +metadata to your Moose classes and attributes. This will allow +you to track out of band data along with attributes, which is +very useful for say serializing Moose classes in HTML or XML. =head1 BUGS