line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::Objects::WithUtils::Hash::Immutable; |
2
|
|
|
|
|
|
|
$List::Objects::WithUtils::Hash::Immutable::VERSION = '2.028003'; |
3
|
98
|
|
|
98
|
|
1086
|
use strictures 2; |
|
98
|
|
|
|
|
426
|
|
|
98
|
|
|
|
|
3392
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
require Role::Tiny; |
6
|
|
|
|
|
|
|
Role::Tiny->apply_roles_to_package( __PACKAGE__, |
7
|
|
|
|
|
|
|
qw/ |
8
|
|
|
|
|
|
|
List::Objects::WithUtils::Role::Hash |
9
|
|
|
|
|
|
|
List::Objects::WithUtils::Role::Hash::Immutable |
10
|
|
|
|
|
|
|
/, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
98
|
|
|
98
|
|
14392
|
use Exporter (); |
|
98
|
|
|
|
|
113
|
|
|
98
|
|
|
|
|
4029
|
|
14
|
|
|
|
|
|
|
our @EXPORT = 'immhash'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
98
|
|
|
98
|
|
162
|
my $pkg = caller; |
18
|
98
|
|
|
98
|
|
358
|
{ no strict 'refs'; |
|
98
|
|
|
|
|
107
|
|
|
98
|
|
|
|
|
10683
|
|
|
98
|
|
|
|
|
112
|
|
19
|
98
|
|
|
|
|
152
|
${"${pkg}::a"} = ${"${pkg}::a"}; ${"${pkg}::b"} = ${"${pkg}::b"}; |
|
98
|
|
|
|
|
223
|
|
|
98
|
|
|
|
|
498
|
|
|
98
|
|
|
|
|
92
|
|
|
98
|
|
|
|
|
144
|
|
|
98
|
|
|
|
|
150
|
|
20
|
|
|
|
|
|
|
} |
21
|
98
|
|
|
|
|
4825
|
goto &Exporter::import |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
1
|
74
|
sub immhash { __PACKAGE__->new(@_) } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
List::Objects::WithUtils::Hash::Immutable - Immutable hash objects |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use List::Objects::WithUtils 'immhash'; |
37
|
|
|
|
|
|
|
my $hash = immhash( foo => 1, bar => 2 ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
These are immutable hash objects; attempting to call list-mutating methods |
42
|
|
|
|
|
|
|
(or modify the backing hash directly) will throw an exception. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This class consumes the following roles, which contain most of the relevant |
45
|
|
|
|
|
|
|
documentation: |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
L |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
(See L for a mutable implementation.) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 immhash |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Creates a new immutable hash object. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 AUTHOR |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Jon Portnoy |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |