File Coverage

blib/lib/Keyword/Anonymous/Object.pm
Criterion Covered Total %
statement 22 22 100.0
branch 3 4 75.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 33 34 97.0


line stmt bran cond sub pod time code
1             package Keyword::Anonymous::Object;
2              
3 2     2   229812 use 5.006;
  2         8  
4 2     2   10 use strict;
  2         8  
  2         60  
5 2     2   9 use warnings;
  2         13  
  2         136  
6             our $VERSION = '1.01';
7              
8 2     2   1190 use Anonymous::Object;
  2         27157  
  2         104  
9              
10 2     2   20 use base 'Import::Export';
  2         3  
  2         1053  
11              
12             our %EX = (
13             object => [qw/all/]
14             );
15              
16             our $ANON = Anonymous::Object->new({
17             object_name => 'Keyword::Object::Anon'
18             });
19              
20             sub object (\$@) {
21 2     2 1 167931 my (undef, $val, %spec) = @_;
22              
23 2         9 %spec = _build_spec(%spec);
24              
25 2         4 my $ref = ref $val;
26              
27 2 50       19 my $anon = $ref eq 'HASH' ? $ANON->hash_to_nested_object($val, %spec)
    100          
28             : $ref eq 'ARRAY' ? $ANON->array_to_nested_object($val, %spec)
29             : die "cannot create Anonymous::Object";
30              
31 2         113483 ${$_[0]} = $anon;
  2         5  
32              
33 2         23 return $_[0];
34             }
35              
36             sub _build_spec {
37             return (
38 2     2   17 clearer => 1,
39             predicate => 1,
40             get => 1,
41             set => 1,
42             ref => 1,
43             reftype => 1,
44             autotype => 1,
45             @_
46             );
47             }
48              
49             1;
50              
51             __END__