line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::MetaDescription; |
2
|
7
|
|
|
7
|
|
3166515
|
use Moose; |
|
7
|
|
|
|
|
14297229
|
|
|
7
|
|
|
|
|
64
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
5
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
363300
|
use MooseX::MetaDescription::Meta::Class; |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
384
|
|
8
|
7
|
|
|
7
|
|
5233
|
use MooseX::MetaDescription::Meta::Attribute; |
|
7
|
|
|
|
|
28
|
|
|
7
|
|
|
|
|
388
|
|
9
|
7
|
|
|
7
|
|
5615
|
use MooseX::MetaDescription::Description; |
|
7
|
|
|
|
|
71
|
|
|
7
|
|
|
|
|
234
|
|
10
|
|
|
|
|
|
|
|
11
|
7
|
|
|
7
|
|
44
|
no Moose; 1; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
31
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__END__ |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=pod |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
MooseX::MetaDescription - A framework for adding additional metadata to Moose classes |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Foo; |
24
|
|
|
|
|
|
|
use metaclass 'MooseX::MetaDescription::Meta::Class' => ( |
25
|
|
|
|
|
|
|
# add class-level metadata |
26
|
|
|
|
|
|
|
description => { |
27
|
|
|
|
|
|
|
'Hello' => 'World' |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
use Moose; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'bar' => ( |
33
|
|
|
|
|
|
|
metaclass => 'MooseX::MetaDescription::Meta::Attribute', |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => 'Str', |
36
|
|
|
|
|
|
|
default => sub { Bar->new() }, |
37
|
|
|
|
|
|
|
# add attribute level metadata |
38
|
|
|
|
|
|
|
description => { |
39
|
|
|
|
|
|
|
node_type => 'element', |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $foo = Foo->new; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$foo->meta->description; # { 'Hello' => 'World' } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $bar = $foo->meta->get_attribute('bar'); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# access the desciption HASH directly |
50
|
|
|
|
|
|
|
$bar->description; # { node_type => 'element' } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# or access the instance of MooseX::MetaDescription::Description |
53
|
|
|
|
|
|
|
$bar->metadescription; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# access the original attribute metaobject from the metadesc too |
56
|
|
|
|
|
|
|
$bar->metadescription->descriptor == $bar; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
MooseX::MetaDescription allows you to add arbitrary out of band |
61
|
|
|
|
|
|
|
metadata to your Moose classes and attributes. This will allow |
62
|
|
|
|
|
|
|
you to track out of band data along with attributes, which is |
63
|
|
|
|
|
|
|
very useful for say serializing Moose classes in HTML or XML. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over 4 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item B<meta> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The Moose metaclass. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 BUGS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
78
|
|
|
|
|
|
|
exception. If you find a bug please either email me, or add the bug |
79
|
|
|
|
|
|
|
to cpan-RT. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Code and Design originally by Jonathan Rockway in the Ernst module, |
84
|
|
|
|
|
|
|
extracted and refactored by: |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Stevan Little E<lt>stevan.little@iinteractive.comE<gt> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Copyright 2008 Infinity Interactive, Inc. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L<http://www.iinteractive.com> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
95
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |