File Coverage

blib/lib/DBIx/SearchBuilder/Util.pm
Criterion Covered Total %
statement 12 12 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 19 19 100.0


line stmt bran cond sub pod time code
1 25     25   173 use strict;
  25         56  
  25         769  
2 25     25   153 use warnings;
  25         61  
  25         920  
3              
4             package DBIx::SearchBuilder::Util;
5 25     25   197 use base 'Exporter';
  25         58  
  25         6281  
6              
7             our @EXPORT_OK = qw(
8             sorted_values
9             );
10              
11             =head1 NAME
12              
13             DBIx::SearchBuilder::Util - Utility and convenience functions for DBIx::SearchBuilder
14              
15             =head1 SYNOPSIS
16              
17             use DBIx::SearchBuilder::Util qw( sorted_values ); # or other function you want
18              
19             =head1 EXPORTED FUNCTIONS
20              
21             =head2 sorted_values
22              
23             Takes a hash or hashref and returns the values sorted by their respective keys.
24              
25             Equivalent to
26              
27             map { $hash{$_} } sort keys %hash
28              
29             but far more convenient.
30              
31             =cut
32              
33             sub sorted_values {
34 325 100   325 1 812 my $hash = @_ == 1 ? $_[0] : { @_ };
35 325         933 return map { $hash->{$_} } sort keys %$hash;
  339         1233  
36             }
37              
38             =head1 LICENSE AND COPYRIGHT
39              
40             Copyright (c) 2013 Best Practical Solutions, LLC. All rights reserved.
41              
42             This library is free software; you can redistribute it and/or modify it under
43             the same terms as Perl itself.
44              
45             =cut
46              
47             1;