inheriting class desc
[gitmo/MooseX-MetaDescription.git] / lib / MooseX / MetaDescription / Meta / Trait.pm
CommitLineData
b70e06c6 1package MooseX::MetaDescription::Meta::Trait;
c13295c8 2use Moose::Role;
3
d9f5e5ae 4our $VERSION = '0.02';
c13295c8 5our $AUTHORITY = 'cpan:STEVAN';
6
7591e02c 7has 'description' => (
8 is => 'ro',
9 isa => 'HashRef',
10 lazy => 1,
11 default => sub { +{} },
12);
13
14has 'metadescription_classname' => (
d9f5e5ae 15 is => 'rw',
7591e02c 16 isa => 'Str',
91297cb4 17 lazy => 1,
7591e02c 18 default => sub {
19 'MooseX::MetaDescription::Description'
d9f5e5ae 20 }
7591e02c 21);
c13295c8 22
7591e02c 23has 'metadescription' => (
24 is => 'ro',
25 isa => 'MooseX::MetaDescription::Description',
26 lazy => 1,
27 default => sub {
28 my $self = shift;
8a18d249 29
30 my $metadesc_class = $self->metadescription_classname;
31 my $desc = $self->description;
32
d9f5e5ae 33 Class::MOP::load_class($metadesc_class);
34
8a18d249 35 if (my $traits = delete $desc->{traits}) {
36 my $meta = Moose::Meta::Class->create_anon_class(
37 superclasses => [ $metadesc_class ],
38 roles => $traits,
39 );
40 $meta->add_method('meta' => sub { $meta });
41 $metadesc_class = $meta->name;
42 }
43
44 return $metadesc_class->new(%$desc, descriptor => $self);
c13295c8 45 },
46);
47
48no Moose::Role; 1;
49
50__END__
51
52=pod
53
54=head1 NAME
55
d253607a 56MooseX::MetaDescription::Meta::Trait - Custom class meta-trait for meta-descriptions
c13295c8 57
58=head1 DESCRIPTION
59
d253607a 60Nothing worth saying yet actually, mostly internal usage only. See the
61SYNPOSIS in L<MooseX::MetaDescription> for an example of usage.
62
c13295c8 63=head1 METHODS
64
65=over 4
66
d253607a 67=item B<description>
68
69=item B<metadescription_classname>
70
71=item B<metadescription>
c13295c8 72
73=back
74
75=head1 BUGS
76
77All complex software has bugs lurking in it, and this module is no
78exception. If you find a bug please either email me, or add the bug
79to cpan-RT.
80
81=head1 AUTHOR
82
83Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
84
85=head1 COPYRIGHT AND LICENSE
86
87Copyright 2008 Infinity Interactive, Inc.
88
89L<http://www.iinteractive.com>
90
91This library is free software; you can redistribute it and/or modify
92it under the same terms as Perl itself.
93
94=cut