1 package MooseX::MetaDescription::Meta::Trait;
5 our $AUTHORITY = 'cpan:STEVAN';
11 default => sub { +{} },
14 has 'metadescription_classname' => (
19 'MooseX::MetaDescription::Description'
23 has 'metadescription' => (
25 isa => 'MooseX::MetaDescription::Description',
30 my $metadesc_class = $self->metadescription_classname;
31 my $desc = $self->description;
33 Class::MOP::load_class($metadesc_class);
35 if (my $traits = delete $desc->{traits}) {
36 my $meta = Moose::Meta::Class->create_anon_class(
37 superclasses => [ $metadesc_class ],
40 $meta->add_method('meta' => sub { $meta });
41 $metadesc_class = $meta->name;
44 return $metadesc_class->new(%$desc, descriptor => $self);
56 MooseX::MetaDescription::Meta::Trait - Custom class meta-trait for meta-descriptions
64 # apply this as a trait to your attribute
65 traits => [ 'MooseX::MetaDescription::Meta::Trait' ],
68 default => sub { 'Foo::baz' },
70 bar => 'Foo::baz::bar',
71 gorch => 'Foo::baz::gorch',
77 This is the core of the Meta Description functionality, it is a role that is done
78 by both L<MooseX::MetaDescription::Meta::Attribute> and L<MooseX::MetaDescription::Meta::Class>
79 and can be used on it's own as a meta-attribute trait.
87 The description C<HASH> ref is stored here.
89 =item B<metadescription_classname>
91 This provides the name of the metadescription class, currently this
92 defaults to L<MooseX::MetaDescription::Description>. It is read only
93 and so can only be specified at instance construction time.
95 =item B<metadescription>
97 This is the instance of the class specified in C<metadescription_classname>
98 it is generated lazily and is also read-only. In general you will never
99 need to set this yourself, but simply set C<metadescription_classname>
100 and it will all just work.
105 The L<Moose::Role> metaclass.
111 All complex software has bugs lurking in it, and this module is no
112 exception. If you find a bug please either email me, or add the bug
117 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
119 =head1 COPYRIGHT AND LICENSE
121 Copyright 2008 Infinity Interactive, Inc.
123 L<http://www.iinteractive.com>
125 This library is free software; you can redistribute it and/or modify
126 it under the same terms as Perl itself.