| 1 | package DBIx::NinjaORM::Utils; | ||||||||||
| 2 | |||||||||||
| 3 | 71 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 71 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 71 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 71 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 71 | ▶ | use Data::Dumper (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 71 | ▶ | use Data::Validate::Type; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 71 | ▶ | use base 'Exporter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 71 | our @EXPORT_OK = qw( | |||||||||
| 15 | dumper | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | =head1 NAME | ||||||||||
| 20 | |||||||||||
| 21 | DBIx::NinjaORM::Utils - Utility functions for L<DBIX::NinjaORM>. | ||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | =head1 VERSION | ||||||||||
| 25 | |||||||||||
| 26 | Version 3.1.0 | ||||||||||
| 27 | |||||||||||
| 28 | =cut | ||||||||||
| 29 | |||||||||||
| 30 | 71 | our $VERSION = '3.1.0'; | |||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||
| 34 | |||||||||||
| 35 | Collection of utility functions used by L<DBIX::NinjaORM> 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 | 71 | our $DUMPER = undef; | |||||||||
| 69 | |||||||||||
| 70 | sub dumper | ||||||||||
| 71 | 4 | ▶ | { | ||||||||
|
Subroutine
dumper: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 72 | 4 | my ( @data ) = @_; | |||||||||
| 73 | |||||||||||
| 74 | 4 | ▶ | if ( defined( $DUMPER ) ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | { | ||||||||||
| 76 | 2 | ▶ | carp "The custom dumper function is not a valid code reference" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | if !Data::Validate::Type::is_coderef( $DUMPER ); | ||||||||||
| 78 | |||||||||||
| 79 | 2 | return $DUMPER->( @data ); | |||||||||
| 80 | } | ||||||||||
| 81 | else | ||||||||||
| 82 | { | ||||||||||
| 83 | 2 | 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<https://github.com/guillaumeaubert/DBIx-NinjaORM/issues/new>. | ||||||||||
| 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<https://github.com/guillaumeaubert/DBIx-NinjaORM/issues> | ||||||||||
| 110 | |||||||||||
| 111 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 112 | |||||||||||
| 113 | L<http://annocpan.org/dist/DBIx-NinjaORM> | ||||||||||
| 114 | |||||||||||
| 115 | =item * CPAN Ratings | ||||||||||
| 116 | |||||||||||
| 117 | L<http://cpanratings.perl.org/d/DBIx-NinjaORM> | ||||||||||
| 118 | |||||||||||
| 119 | =item * MetaCPAN | ||||||||||
| 120 | |||||||||||
| 121 | L<https://metacpan.org/release/DBIx-NinjaORM> | ||||||||||
| 122 | |||||||||||
| 123 | =back | ||||||||||
| 124 | |||||||||||
| 125 | |||||||||||
| 126 | =head1 AUTHOR | ||||||||||
| 127 | |||||||||||
| 128 | Guillaume Aubert, C<< <aubertg at cpan.org> >>. | ||||||||||
| 129 | |||||||||||
| 130 | |||||||||||
| 131 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 132 | |||||||||||
| 133 | Copyright 2009-2017 Guillaume Aubert. | ||||||||||
| 134 | |||||||||||
| 135 | This code is free software; you can redistribute it and/or modify it under the | ||||||||||
| 136 | same terms as Perl 5 itself. | ||||||||||
| 137 | |||||||||||
| 138 | This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||||||||||
| 139 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||||||||||
| 140 | PARTICULAR PURPOSE. See the LICENSE file for more details. | ||||||||||
| 141 | |||||||||||
| 142 | =cut | ||||||||||
| 143 | |||||||||||
| 144 | 71 | 1; | |||||||||
| 145 | |||||||||||