File Coverage

blib/lib/List/Objects/WithUtils/Hash/Immutable.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 25 25 100.0


line stmt bran cond sub pod time code
1             package List::Objects::WithUtils::Hash::Immutable;
2             $List::Objects::WithUtils::Hash::Immutable::VERSION = '2.027002';
3 98     98   1763 use strictures 2;
  98         621  
  98         4358  
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   23132 use Exporter ();
  98         183  
  98         5061  
14             our @EXPORT = 'immhash';
15              
16             sub import {
17 98     98   264 my $pkg = caller;
18 98     98   536 { no strict 'refs';
  98         211  
  98         14628  
  98         179  
19 98         169 ${"${pkg}::a"} = ${"${pkg}::a"}; ${"${pkg}::b"} = ${"${pkg}::b"};
  98         401  
  98         439  
  98         163  
  98         264  
  98         282  
20             }
21 98         6555 goto &Exporter::import
22             }
23              
24 3     3 1 91 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