From: Stevan Little Date: Fri, 2 May 2008 15:57:37 +0000 (+0000) Subject: twweaking X-Git-Tag: 0.04~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-MetaDescription.git;a=commitdiff_plain;h=c6936f018be9a77f44c72336bd0ce036827d4071 twweaking --- diff --git a/lib/MooseX/MetaDescription.pm b/lib/MooseX/MetaDescription.pm index 4606763..c45b6b4 100644 --- a/lib/MooseX/MetaDescription.pm +++ b/lib/MooseX/MetaDescription.pm @@ -21,13 +21,18 @@ 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', } @@ -36,12 +41,24 @@ MooseX::MetaDescription - A framework for adding additional metadata to Moose cl ... $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; # { baz => 'Foo::bar::baz' } + + # 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. +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