File Coverage

blib/lib/DBIx/Class/Smooth/Lookup/DateTime/datepart.pm
Criterion Covered Total %
statement 17 36 47.2
branch 0 2 0.0
condition n/a
subroutine 6 8 75.0
pod 0 1 0.0
total 23 47 48.9


line stmt bran cond sub pod time code
1 2     2   893 use 5.20.0;
  2         9  
2 2     2   11 use strict;
  2         4  
  2         38  
3 2     2   11 use warnings;
  2         4  
  2         155  
4              
5             package DBIx::Class::Smooth::Lookup::DateTime::datepart;
6              
7             # ABSTRACT: Short intro
8             our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9             our $VERSION = '0.0101';
10              
11 2     2   14 use parent 'DBIx::Class::Smooth::Lookup::Util';
  2         4  
  2         10  
12 2     2   161 use Carp qw/carp confess/;
  2         7  
  2         123  
13 2     2   14 use experimental qw/signatures postderef/;
  2         4  
  2         12  
14              
15 0     0 0   sub smooth__lookup__datepart($self, $column_name, $value, $params, @rest) {
  0            
  0            
  0            
  0            
  0            
  0            
16 0           $self->smooth__lookup_util__ensure_param_count('substring', $params, { at_least => 1, at_most => 1, regex => qr/^[a-z_]+$/i });
17              
18 0           my $datepart = $params->[0];
19              
20 0     0     local $SIG{'__WARN__'} = sub ($message) {
  0            
  0            
21 0 0         if($message =~ m{uninitialized value within %part_map}) {
22 0           confess "<datepart> was passed <$datepart> as the datepart, but your database don't support that";
23             }
24             else {
25 0           warn $message;
26             }
27 0           };
28              
29 0           my $complete = $self->dt_SQL_pluck({ -ident => $column_name }, $datepart);
30              
31 0           my $function_call_string = $complete->$*->[0];
32              
33 0           return { left_hand_function => { complete => $function_call_string }, value => $value };
34             }
35              
36             1;
37              
38             __END__
39              
40             =pod
41              
42             =encoding UTF-8
43              
44             =head1 NAME
45              
46             DBIx::Class::Smooth::Lookup::DateTime::datepart - Short intro
47              
48             =head1 VERSION
49              
50             Version 0.0101, released 2018-11-29.
51              
52             =head1 SOURCE
53              
54             L<https://github.com/Csson/p5-DBIx-Class-Smooth>
55              
56             =head1 HOMEPAGE
57              
58             L<https://metacpan.org/release/DBIx-Class-Smooth>
59              
60             =head1 AUTHOR
61              
62             Erik Carlsson <info@code301.com>
63              
64             =head1 COPYRIGHT AND LICENSE
65              
66             This software is copyright (c) 2018 by Erik Carlsson.
67              
68             This is free software; you can redistribute it and/or modify it under
69             the same terms as the Perl 5 programming language system itself.
70              
71             =cut