List/Objects/WithUtils/Hash/Typed.pm

filter: Statementstmt 100% 24 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 30 / 30 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
import
1.0
CRAP 1.0
« List/Objects/WithUtils/Array/Immutable.pm ↑ Summary List/Objects/WithUtils/Role/Array/TiedRO.pm »
1 package List::Objects::WithUtils::Hash::Typed;
2 99 $List::Objects::WithUtils::Hash::Typed::VERSION = '2.028002';
3 99 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 99 require Role::Tiny;
6 99 Role::Tiny->apply_roles_to_package( __PACKAGE__,
7 qw/
8 List::Objects::WithUtils::Role::Hash
9 List::Objects::WithUtils::Role::Hash::Typed
10 /
11 );
12  
13 99 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 99 our @EXPORT = 'hash_of';
15  
16 sub import {
17 100 ▶ my $pkg = caller;
Subroutine import: called CC=1 SCAR=0.0
18 99 ▶ { no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 100 ${"${pkg}::a"} = ${"${pkg}::a"}; ${"${pkg}::b"} = ${"${pkg}::b"};
20 }
21 100 goto &Exporter::import
22 }
23  
24 6 ▶sub hash_of { __PACKAGE__->new(@_) }
Subroutine hash_of: called CC=1 SCAR=0.0
Pod documented
25  
26 99 1;
27  
28  
29 =pod
30  
31 =head1 NAME
32  
33 List::Objects::WithUtils::Hash::Typed - Type-checking hash objects
34  
35 =head1 SYNOPSIS
36  
37 use List::Objects::WithUtils 'hash_of';
38  
39 use Types::Standard -all;
40  
41 my $arr = hash_of Int() => ( foo => 1, bar => 2 );
42  
43 =head1 DESCRIPTION
44  
45 These are type-checking hash objects; values are checked against the specified
46 type when the object is constructed or new elements are added.
47  
48 The first argument passed to the constructor should be a L<Type::Tiny> type:
49  
50 use Types::Standard -all;
51 my $hash = hash_of Int() => ( foo => 1 );
52  
53 If the initial type-check fails, a coercion is attempted.
54  
55 This class consumes the following roles, which contain most of the relevant
56 documentation:
57  
58 L<List::Objects::WithUtils::Role::Hash>
59  
60 L<List::Objects::WithUtils::Role::Hash::Typed>
61  
62 Also see L<Types::Standard>, L<List::Objects::Types>
63  
64 =head2 hash_of
65  
66 Creates a new typed hash object.
67  
68 =head1 AUTHOR
69  
70 Jon Portnoy <avenj@cobaltirc.org> with significant contributions from Toby
71 Inkster (CPAN: TOBYINK)
72  
73 =cut
« List/Objects/WithUtils/Array/Immutable.pm ↑ Summary List/Objects/WithUtils/Role/Array/TiedRO.pm »