File Coverage

blib/lib/DBIx/Class/Helper/ResultSet/Shortcut/Search/Base.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 4 100.0
condition 5 6 83.3
subroutine 6 6 100.0
pod n/a
total 38 39 97.4


line stmt bran cond sub pod time code
1             package DBIx::Class::Helper::ResultSet::Shortcut::Search::Base;
2             $DBIx::Class::Helper::ResultSet::Shortcut::Search::Base::VERSION = '2.035000';
3 57     57   29562 use strict;
  57         165  
  57         1651  
4 57     57   356 use warnings;
  57         148  
  57         1547  
5              
6 57     57   321 use parent 'DBIx::Class::ResultSet';
  57         145  
  57         476  
7              
8             #--------------------------------------------------------------------------#
9             # _helper_unwrap_columns(@columns)
10             #--------------------------------------------------------------------------#
11              
12             sub _helper_unwrap_columns {
13 7     7   97 my ($self, @columns) = @_;
14              
15 7 100 100     81 if (@columns == 1 && ref($columns[0]) && ref($columns[0]) eq 'ARRAY') {
      66        
16 2         6 @columns = @{ $columns[0] };
  2         9  
17             }
18              
19 7         33 return @columns;
20             }
21              
22             #--------------------------------------------------------------------------#
23             # _helper_meify($column)
24             #--------------------------------------------------------------------------#
25              
26             sub _helper_meify {
27 8     8   31 my ($self, $column) = @_;
28              
29 8 100       80 return $self->current_source_alias . $column if $column =~ m/^\./;
30 6         50 return $column;
31             }
32              
33             #--------------------------------------------------------------------------#
34             # _helper_apply_search($cond, @columns)
35             #--------------------------------------------------------------------------#
36              
37             sub _helper_apply_search {
38 5     5   23 my ($self, $cond, @columns) = @_;
39              
40 5         38 @columns = $self->_helper_unwrap_columns(@columns);
41              
42 5         15 my $rs = $self;
43 5         16 foreach my $column (@columns) {
44 6         269 $rs = $rs->search_rs({ $self->_helper_meify($column) => $cond });
45             }
46              
47 5         3350 return $rs;
48             }
49              
50              
51             1;
52              
53             __END__
54              
55             =pod
56              
57             =head1 NAME
58              
59             DBIx::Class::Helper::ResultSet::Shortcut::Search::Base
60              
61             =head1 AUTHOR
62              
63             Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
64              
65             =head1 COPYRIGHT AND LICENSE
66              
67             This software is copyright (c) 2020 by Arthur Axel "fREW" Schmidt.
68              
69             This is free software; you can redistribute it and/or modify it under
70             the same terms as the Perl 5 programming language system itself.
71              
72             =cut