additional docs
[gitmo/MooseX-MetaDescription.git] / lib / MooseX / MetaDescription / Meta / Trait.pm
index fd1decb..11ccb01 100644 (file)
@@ -26,10 +26,20 @@ has 'metadescription' => (
     lazy    => 1,   
     default => sub {
         my $self = shift;
-        $self->metadescription_classname->new(
-            %{ $self->description },
-            descriptor => $self,
-        );
+        
+        my $metadesc_class = $self->metadescription_classname;
+        my $desc           = $self->description;
+        
+        if (my $traits = delete $desc->{traits}) {
+            my $meta = Moose::Meta::Class->create_anon_class(
+                superclasses => [ $metadesc_class ],
+                roles        => $traits,
+            );
+            $meta->add_method('meta' => sub { $meta });
+            $metadesc_class = $meta->name;
+        }
+        
+        return $metadesc_class->new(%$desc, descriptor => $self);
     },
 );
 
@@ -41,19 +51,22 @@ __END__
 
 =head1 NAME
 
-MooseX::MetaDescription::Meta::Trait - A Moosey solution to this problem
-
-=head1 SYNOPSIS
-
-  use MooseX::MetaDescription::Meta::Trait;
+MooseX::MetaDescription::Meta::Trait - Custom class meta-trait for meta-descriptions
 
 =head1 DESCRIPTION
 
+Nothing worth saying yet actually, mostly internal usage only. See the 
+SYNPOSIS in L<MooseX::MetaDescription> for an example of usage.
+
 =head1 METHODS 
 
 =over 4
 
-=item B<>
+=item B<description>
+
+=item B<metadescription_classname>
+
+=item B<metadescription>
 
 =back