Prototype/Collection.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 23 CC 1 SCAR 6.9
CC
1
Cov
0%
add_prototype
2.0
set_referenced
2.0
BEGIN
2.0
CRAP 2.0
1 # Collection Class for prototypes;
2 # Key is role/prototype
3 #
4 package MooseX::Attribute::Prototype::Collection;
5  
6 use Moose;
7 use MooseX::AttributeHelpers;
8  
9 our $VERSION = '0.10';
10 our $AUTHORITY = 'cpan:CTBROWN';
11  
12 has 'prototypes' => (
13 is => 'rw' ,
14 isa => 'HashRef[MooseX::Attribute::Prototype::Object]' ,
15 default => sub { {} } ,
16 documentation => 'Slot containing hash of attribute prototypes' ,
17 metaclass => 'Collection::Hash' ,
18 provides => {
19 set => 'set' ,
20 get => 'get' ,
21 count => 'count' ,
22 exists => 'exists' ,
23 keys => 'keys' ,
24 } ,
25 );
26  
27
28  
29 # This is a simplified interface for set where you pass a prototype instead
30 # of a name => prototype.
31 sub add_prototype {
32
33 my ( $self, $prototype ) = @_;
34 $self->set( $prototype->name, $prototype );
35  
36 }
37  
38  
39 # set the reference property of the attribute described by key
40 sub set_referenced {
41  
42 $_[0]->get( $_[1] )->referenced(1);
43  
44
45 }
46  
47  
48 no Moose;
49  
50 =pod
51  
52 =head1 NAME
53  
54 MooseX::Attribute::Prototype::Collection - Container class for MooseX::Attribute::Prototype::Object
55  
56 =head1 VERSION
57  
58 0.10 - Released 2009-07-18
59  
60 =head1 SYNOPSIS
61  
62 use MooseX::Attribute::Prototype::Collection
63 $collection = MooseX::Attribute::Prototype::Collection->new();
64  
65 # Add a MooseX::Attribute::Prototype::Object
66 $collection->add_prototype( $prototype );
67  
68 # Retrieve a prototype from the collections
69 $collection->get( 'MyRole/attr' );
70
71 # Check if a prototype exists
72 $collection->exists( 'MyRole/attr' );
73  
74  
75 =head1 DESCRIPTION
76  
77 This class is used internally by MooseX::Attribute::Prototype
78 it serves as a container for holding the prototype objects. There is
79 (as of yet) little reason to use this class directly.
80  
81 =head1 SEE ALSO
82  
83 L<MooseX::Attribute::Prototype>,
84  
85 L<MooseX::Attribute::Prototype::Meta>,
86  
87 L<MooseX::Attribute::Prototype::Object>,
88  
89 L<Moose>
90  
91 L<MooseX::Role::Parameterized>
92  
93 L<MooseX::Types>
94  
95  
96 =head1 AUTHOR
97  
98 Christopher Brown, C<< <ctbrown at cpan.org> >>
99  
100 =head1 BUGS
101  
102 Please report any bugs or feature requests to C<bug-moosex-attribute-prototype at rt.cpan.org>, or through
103 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Attribute-Prototype>. I will be notified, and then you'll
104 automatically be notified of progress on your bug as I make changes.
105  
106  
107 =head1 SUPPORT
108  
109 You can find documentation for this module with the perldoc command.
110  
111 perldoc MooseX::Attribute::Prototype
112  
113 You can also look for information at:
114  
115 =over 4
116  
117 =item * RT: CPAN's request tracker
118  
119 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Attribute-Prototype>
120  
121 =item * AnnoCPAN: Annotated CPAN documentation
122  
123 L<http://annocpan.org/dist/MooseX-Attribute-Prototype>
124  
125 =item * CPAN Ratings
126  
127 L<http://cpanratings.perl.org/d/MooseX-Attribute-Prototype>
128  
129 =item * Search CPAN
130  
131 L<http://search.cpan.org/dist/MooseX-Attribute-Prototype>
132  
133 =back
134  
135  
136 =head1 ACKNOWLEDGEMENTS
137  
138 Though they would probably cringe to hear it, this effort would not have
139 been possible without:
140  
141 Shawn Moore
142  
143 David Rolsky
144  
145 Thomas Doran
146  
147 Stevan Little
148  
149  
150 =head1 COPYRIGHT & LICENSE
151  
152 Copyright 2009 Christopher Brown and Open Data Group L<http://opendatagroup.com>.
153  
154 This program is free software; you can redistribute it and/or modify it
155 under the same terms as Perl itself.
156  
157  
158 =cut
159  
160 1; # End of MooseX::Attribute::Prototype
161  
162