File Coverage

blib/lib/DBIx/NinjaORM/Utils.pm
Criterion Covered Total %
statement 26 26 100.0
branch 3 4 75.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 38 39 97.4


line stmt bran cond sub pod time code
1             package DBIx::NinjaORM::Utils;
2              
3 71     71   76364 use 5.010;
  71         240  
  71         2991  
4              
5 71     71   429 use strict;
  71         130  
  71         2347  
6 71     71   406 use warnings;
  71         165  
  71         2216  
7              
8 71     71   439 use Carp;
  71         196  
  71         4751  
9 71     71   104930 use Data::Dumper ();
  71         637064  
  71         2164  
10 71     71   2444 use Data::Validate::Type;
  71         19544  
  71         3857  
11              
12 71     71   431 use base 'Exporter';
  71         154  
  71         25196  
13              
14             our @EXPORT_OK = qw(
15             dumper
16             );
17              
18              
19             =head1 NAME
20              
21             DBIx::NinjaORM::Utils - Utility functions for L.
22              
23              
24             =head1 VERSION
25              
26             Version 3.0.2
27              
28             =cut
29              
30             our $VERSION = '3.0.2';
31              
32              
33             =head1 DESCRIPTION
34              
35             Collection of utility functions used by L to perform various
36             ancillary tasks.
37              
38              
39             =head1 SYNOPSIS
40              
41             use DBIx::NinjaORM::Utils qw( dumper );
42              
43             my $string = dumper( $data_structure );
44              
45              
46             =head1 FUNCTIONS
47              
48             =head2 dumper()
49              
50             Utility to stringify data structures.
51              
52             my $string = DBIx::NinjaORM::Utils::dumper( @data );
53              
54             Internally, this uses Data::Dumper::Dumper, but you can switch it to a custom
55             dumper with the following code:
56              
57             local $DBIx::NinjaORM::Utils::DUMPER = sub
58             {
59             my ( @refs ) = @_;
60              
61             # Create a stringified version.
62              
63             return $string;
64             };
65              
66             =cut
67              
68             our $DUMPER = undef;
69              
70             sub dumper
71             {
72 4     4 1 5135 my ( @data ) = @_;
73              
74 4 100       20 if ( defined( $DUMPER ) )
75             {
76 2 50       16 carp "The custom dumper function is not a valid code reference"
77             if !Data::Validate::Type::is_coderef( $DUMPER );
78              
79 2         36 return $DUMPER->( @data );
80             }
81             else
82             {
83 2         19 return Data::Dumper::Dumper( @data );
84             }
85             }
86              
87              
88             =head1 BUGS
89              
90             Please report any bugs or feature requests through the web interface at
91             L.
92             I will be notified, and then you'll automatically be notified of progress on
93             your bug as I make changes.
94              
95              
96             =head1 SUPPORT
97              
98             You can find documentation for this module with the perldoc command.
99              
100             perldoc DBIx::NinjaORM::Utils
101              
102              
103             You can also look for information at:
104              
105             =over 4
106              
107             =item * GitHub's request tracker
108              
109             L
110              
111             =item * AnnoCPAN: Annotated CPAN documentation
112              
113             L
114              
115             =item * CPAN Ratings
116              
117             L
118              
119             =item * MetaCPAN
120              
121             L
122              
123             =back
124              
125              
126             =head1 AUTHOR
127              
128             Guillaume Aubert, C<< >>.
129              
130              
131             =head1 COPYRIGHT & LICENSE
132              
133             Copyright 2009-2014 Guillaume Aubert.
134              
135             This program is free software: you can redistribute it and/or modify it under
136             the terms of the GNU General Public License version 3 as published by the Free
137             Software Foundation.
138              
139             This program is distributed in the hope that it will be useful, but WITHOUT ANY
140             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
141             PARTICULAR PURPOSE. See the GNU General Public License for more details.
142              
143             You should have received a copy of the GNU General Public License along with
144             this program. If not, see http://www.gnu.org/licenses/
145              
146             =cut
147              
148             1;
149