Version 0.05
[gitmo/MooseX-MetaDescription.git] / lib / MooseX / MetaDescription.pm
index 5dcf4bd..ef618f7 100644 (file)
@@ -1,11 +1,12 @@
 package MooseX::MetaDescription;
 use Moose;
 
+our $VERSION   = '0.05';
+our $AUTHORITY = 'cpan:STEVAN';
+
 use MooseX::MetaDescription::Meta::Class;
 use MooseX::MetaDescription::Meta::Attribute;
-
-our $VERSION   = '0.01';
-our $AUTHORITY = 'cpan:STEVAN';
+use MooseX::MetaDescription::Description;
 
 no Moose; 1;
 
@@ -15,19 +16,59 @@ __END__
 
 =head1 NAME
 
-MooseX::MetaDescription - A Moosey solution to this problem
+MooseX::MetaDescription - A framework for adding additional metadata to Moose classes
 
 =head1 SYNOPSIS
 
-  use MooseX::MetaDescription;
+  package Foo;
+  use metaclass 'MooseX::MetaDescription::Meta::Class' => (
+      # add class-level metadata
+      description => {
+          'Hello' => 'World'
+      }
+  );
+  use Moose;
+  
+  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' }
+  
+  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
 
-=head1 METHODS 
+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<>
+=item B<meta>
+
+The Moose metaclass.
 
 =back
 
@@ -39,6 +80,9 @@ to cpan-RT.
 
 =head1 AUTHOR
 
+Code and Design originally by Jonathan Rockway in the Ernst module, 
+extracted and refactored by:
+
 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE