line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::AttributeHelpers::MethodProvider::ImmutableHash; |
2
|
22
|
|
|
22
|
|
9980
|
use Moose::Role; |
|
22
|
|
|
|
|
74
|
|
|
22
|
|
|
|
|
111
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.25'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub exists : method { |
7
|
2
|
|
|
2
|
1
|
12
|
my ($attr, $reader, $writer) = @_; |
8
|
2
|
100
|
|
4
|
|
25
|
return sub { CORE::exists $reader->($_[0])->{$_[1]} ? 1 : 0 }; |
|
4
|
|
|
20
|
|
2896
|
|
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub defined : method { |
12
|
2
|
|
|
2
|
1
|
9
|
my ($attr, $reader, $writer) = @_; |
13
|
2
|
50
|
|
2
|
|
10
|
return sub { CORE::defined $reader->($_[0])->{$_[1]} ? 1 : 0 }; |
|
2
|
|
|
|
|
10
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get : method { |
17
|
4
|
|
|
6
|
1
|
20
|
my ($attr, $reader, $writer) = @_; |
18
|
|
|
|
|
|
|
return sub { |
19
|
14
|
100
|
|
14
|
|
7116
|
if ( @_ == 2 ) { |
20
|
10
|
|
|
|
|
39
|
$reader->($_[0])->{$_[1]} |
21
|
|
|
|
|
|
|
} else { |
22
|
4
|
|
|
|
|
11
|
my ( $self, @keys ) = @_; |
23
|
4
|
|
|
|
|
5
|
@{ $reader->($self) }{@keys} |
|
4
|
|
|
|
|
17
|
|
24
|
|
|
|
|
|
|
} |
25
|
4
|
|
|
|
|
37
|
}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub keys : method { |
29
|
0
|
|
|
6
|
1
|
0
|
my ($attr, $reader, $writer) = @_; |
30
|
0
|
|
|
0
|
|
0
|
return sub { CORE::keys %{$reader->($_[0])} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub values : method { |
34
|
0
|
|
|
0
|
1
|
0
|
my ($attr, $reader, $writer) = @_; |
35
|
0
|
|
|
0
|
|
0
|
return sub { CORE::values %{$reader->($_[0])} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub kv : method { |
39
|
2
|
|
|
2
|
1
|
10
|
my ($attr, $reader, $writer) = @_; |
40
|
|
|
|
|
|
|
return sub { |
41
|
2
|
|
|
2
|
|
64
|
my $h = $reader->($_[0]); |
42
|
|
|
|
|
|
|
map { |
43
|
6
|
|
|
|
|
23
|
[ $_, $h->{$_} ] |
44
|
2
|
|
|
|
|
31
|
} CORE::keys %{$h} |
|
2
|
|
|
|
|
8
|
|
45
|
2
|
|
|
|
|
12
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub elements : method { |
49
|
2
|
|
|
4
|
1
|
11
|
my ($attr, $reader, $writer) = @_; |
50
|
|
|
|
|
|
|
return sub { |
51
|
2
|
|
|
2
|
|
1487
|
my $h = $reader->($_[0]); |
52
|
|
|
|
|
|
|
map { |
53
|
6
|
|
|
|
|
14
|
$_, $h->{$_} |
54
|
2
|
|
|
|
|
50
|
} CORE::keys %{$h} |
|
2
|
|
|
|
|
6
|
|
55
|
2
|
|
|
|
|
12
|
}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub count : method { |
59
|
4
|
|
|
6
|
1
|
22
|
my ($attr, $reader, $writer) = @_; |
60
|
4
|
|
|
16
|
|
33
|
return sub { scalar CORE::keys %{$reader->($_[0])} }; |
|
16
|
|
|
|
|
2228
|
|
|
16
|
|
|
|
|
58
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub empty : method { |
64
|
4
|
|
|
20
|
1
|
23
|
my ($attr, $reader, $writer) = @_; |
65
|
4
|
100
|
|
8
|
|
33
|
return sub { scalar CORE::keys %{$reader->($_[0])} ? 1 : 0 }; |
|
8
|
|
|
|
|
17928
|
|
|
8
|
|
|
|
|
36
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
MooseX::AttributeHelpers::MethodProvider::ImmutableHash |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
version 0.25 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 DESCRIPTION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This is a role which provides the method generators for |
87
|
|
|
|
|
|
|
L<MooseX::AttributeHelpers::Collection::ImmutableHash>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 METHODS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over 4 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item B<meta> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 PROVIDED METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item B<count> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns the number of elements in the list. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item B<empty> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
If the list is populated, returns true. Otherwise, returns false. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item B<exists> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns true if the given key is present in the hash |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item B<defined> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns true if the value of a given key is defined |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item B<get> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns an element of the hash by its key. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item B<keys> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns the list of keys in the hash. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item B<values> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Returns the list of values in the hash. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item B<kv> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns the key, value pairs in the hash as array references |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item B<elements> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Returns the key, value pairs in the hash as a flattened list |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SUPPORT |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-AttributeHelpers> |
142
|
|
|
|
|
|
|
(or L<bug-MooseX-AttributeHelpers@rt.cpan.org|mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>). |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
145
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
148
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Stevan Little <stevan@iinteractive.com> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Stevan Little and Infinity Interactive, Inc. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
159
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |