File Coverage

blib/lib/MooseX/Types/Tied/Hash/IxHash.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 28 28 100.0


line stmt bran cond sub pod time code
1             #
2             # This file is part of MooseX-Types-Tied
3             #
4             # This software is Copyright (c) 2011 by Chris Weyl.
5             #
6             # This is free software, licensed under:
7             #
8             # The GNU Lesser General Public License, Version 2.1, February 1999
9             #
10             package MooseX::Types::Tied::Hash::IxHash;
11             {
12             $MooseX::Types::Tied::Hash::IxHash::VERSION = '0.003';
13             }
14              
15             # ABSTRACT: Moose type library for Tie::IxHash tied hashes
16              
17 2     2   1291123 use strict;
  2         5  
  2         90  
18 2     2   12 use warnings;
  2         5  
  2         84  
19              
20 2     2   2399 use MooseX::Types -declare => [ qw{ IxHash } ];
  2         117654  
  2         18  
21             #use namespace::clean;
22              
23 2     2   16435 use Scalar::Util qw{ blessed };
  2         4  
  2         117  
24 2     2   1810 use Tie::IxHash;
  2         11575  
  2         68  
25 2     2   1653 use MooseX::Types::Moose ':all';
  2         32581  
  2         27  
26 2     2   19655 use MooseX::Types::Tied ':all';
  2         8  
  2         14  
27              
28             subtype IxHash,
29             as TiedHash,
30             where { blessed(tied %$_) eq 'Tie::IxHash' },
31             message { 'Referenced hash is not tied to an Tie::IxHash: ' . ref tied $_ },
32             ;
33              
34             coerce IxHash,
35             from ArrayRef,
36             via { tie my %x, 'Tie::IxHash', @{$_}; \%x },
37             ;
38              
39             1;
40              
41              
42              
43             =pod
44              
45             =encoding utf-8
46              
47             =head1 NAME
48              
49             MooseX::Types::Tied::Hash::IxHash - Moose type library for Tie::IxHash tied hashes
50              
51             =head1 VERSION
52              
53             This document describes version 0.003 of MooseX::Types::Tied::Hash::IxHash - released April 21, 2012 as part of MooseX-Types-Tied.
54              
55             =head1 SYNOPSIS
56              
57             use Moose;
58             use MooseX::Types::Tied::Hash::IxHash ':all';
59              
60             has tied_array => (is => 'ro', isa => IxHash);
61              
62             # etc...
63              
64             =head1 DESCRIPTION
65              
66             This is a collection of L<Moose> types and coercion settings for L<Tie::IxHash>
67             tied hashes.
68              
69             The package behaves as you'd expect a L<MooseX::Types> library to act: either
70             specify the types you want imported explicitly or use the ':all' catchall.
71              
72             =for stopwords TiedArray TiedHash TiedHandle IxHash
73              
74             =head1 TYPES
75              
76             =head2 IxHash
77              
78             Base type: TiedHash
79              
80             This type coerces from ArrayRef. As of 0.004 we no longer coerce from
81             HashRef, as that lead to 1) annoyingly easy to miss errors involving expecting
82             C<$thing->attribute( { a => 1, b => 2, ... } )> to result in proper ordering;
83             and 2) the Hash native trait appearing to work normally but instead silently
84             destroying the preserved order (during certain write operations).
85              
86             =head1 WARNING!
87              
88             This type is not compatible with the write operations allowed by the Hash
89             Moose native attribute trait.
90              
91             =head1 SEE ALSO
92              
93             Please see those modules/websites for more information related to this module.
94              
95             =over 4
96              
97             =item *
98              
99             L<MooseX::Types::Tied|MooseX::Types::Tied>
100              
101             =back
102              
103             =head1 SOURCE
104              
105             The development version is on github at L<http://github.com/RsrchBoy/moosex-types-tied>
106             and may be cloned from L<git://github.com/RsrchBoy/moosex-types-tied.git>
107              
108             =head1 BUGS
109              
110             Please report any bugs or feature requests on the bugtracker website
111             https://github.com/RsrchBoy/moosex-types-tied/issues
112              
113             When submitting a bug or request, please include a test-file or a
114             patch to an existing test-file that illustrates the bug or desired
115             feature.
116              
117             =head1 AUTHOR
118              
119             Chris Weyl <cweyl@alumni.drew.edu>
120              
121             =head1 COPYRIGHT AND LICENSE
122              
123             This software is Copyright (c) 2011 by Chris Weyl.
124              
125             This is free software, licensed under:
126              
127             The GNU Lesser General Public License, Version 2.1, February 1999
128              
129             =cut
130              
131              
132             __END__
133