line |
stmt |
bran |
cond |
sub |
code |
1
|
|
|
|
|
package List::Objects::WithUtils::Hash::Immutable::Typed; |
2
|
14
|
|
|
14
|
use strictures 1; |
|
14
|
|
|
|
|
|
14
|
|
|
|
|
3
|
|
|
|
|
|
4
|
|
|
|
|
require Role::Tiny; |
5
|
|
|
|
|
Role::Tiny->apply_roles_to_package( __PACKAGE__, |
6
|
|
|
|
|
qw/ |
7
|
|
|
|
|
List::Objects::WithUtils::Role::Hash |
8
|
|
|
|
|
List::Objects::WithUtils::Role::Hash::Typed |
9
|
|
|
|
|
List::Objects::WithUtils::Role::Hash::Immutable |
10
|
|
|
|
|
/ |
11
|
|
|
|
|
); |
12
|
|
|
|
|
|
13
|
14
|
|
|
14
|
use Exporter 'import'; |
|
14
|
|
|
|
|
|
14
|
|
|
|
|
14
|
|
|
|
|
our @EXPORT = 'immhash_of'; |
15
|
2
|
|
|
2
|
sub immhash_of { __PACKAGE__->new(@_) } |
16
|
|
|
|
|
|
17
|
|
|
|
|
1; |
18
|
|
|
|
|
|
19
|
|
|
|
|
=pod |
20
|
|
|
|
|
|
21
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
23
|
|
|
|
|
List::Objects::WithUtils::Hash::Immutable::Typed - Immutable typed hashes |
24
|
|
|
|
|
|
25
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
27
|
|
|
|
|
use List::Objects::WithUtils 'immhash_of'; |
28
|
|
|
|
|
use Types::Standard -types; |
29
|
|
|
|
|
my $hash = immhash_of Int() => ( foo => 1, bar => 2 ); |
30
|
|
|
|
|
|
31
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
33
|
|
|
|
|
These are immutable type-checking hash objects, essentially a combination of |
34
|
|
|
|
|
L<List::Objects::WithUtils::Hash::Typed> and |
35
|
|
|
|
|
L<List::Objects::WithUtils::Hash::Immutable>. |
36
|
|
|
|
|
|
37
|
|
|
|
|
Type-checking is performed when |
38
|
|
|
|
|
the object is created; attempts to modify the object will throw an exception. |
39
|
|
|
|
|
|
40
|
|
|
|
|
This class consumes the following roles, which contain most of the relevant |
41
|
|
|
|
|
documentation: |
42
|
|
|
|
|
|
43
|
|
|
|
|
L<List::Objects::WithUtils::Role::Hash> |
44
|
|
|
|
|
|
45
|
|
|
|
|
L<List::Objects::WithUtils::Role::Hash::Typed> |
46
|
|
|
|
|
|
47
|
|
|
|
|
L<List::Objects::WithUtils::Role::Hash::Immutable> |
48
|
|
|
|
|
|
49
|
|
|
|
|
=head2 immhash_of |
50
|
|
|
|
|
|
51
|
|
|
|
|
Creates a new immutable typed hash object. |
52
|
|
|
|
|
|
53
|
|
|
|
|
=head1 AUTHOR |
54
|
|
|
|
|
|
55
|
|
|
|
|
Jon Portnoy <avenj@cobaltirc.org> |
56
|
|
|
|
|
|
57
|
|
|
|
|
=cut |
58
|
|
|
|
|
|