File Coverage

blib/lib/YAML/PP/Schema/Tie/IxHash.pm
Criterion Covered Total %
statement 12 22 54.5
branch 0 2 0.0
condition n/a
subroutine 4 6 66.6
pod 1 1 100.0
total 17 31 54.8


line stmt bran cond sub pod time code
1 1     1   141990 use strict;
  1         1  
  1         34  
2 1     1   3 use warnings;
  1         2  
  1         100  
3             package YAML::PP::Schema::Tie::IxHash;
4              
5             our $VERSION = 'v0.40.0'; # VERSION
6              
7 1     1   4 use base 'YAML::PP::Schema';
  1         5  
  1         410  
8              
9 1     1   6 use Scalar::Util qw/ blessed reftype /;
  1         1  
  1         143  
10             my $ixhash = eval { require Tie::IxHash };
11              
12             sub register {
13 0     0 1   my ($self, %args) = @_;
14 0           my $schema = $args{schema};
15 0 0         unless ($ixhash) {
16 0           die "You need to install Tie::IxHash in order to use this module";
17             }
18              
19             $schema->add_representer(
20             tied_equals => 'Tie::IxHash',
21             code => sub {
22 0     0     my ($rep, $node) = @_;
23 0           $node->{items} = [ %{ $node->{data} } ];
  0            
24 0           return 1;
25             },
26 0           );
27 0           return;
28             }
29              
30             1;
31              
32             __END__