File Coverage

blib/lib/DBIx/Class/CDBICompat/GetSet.pm
Criterion Covered Total %
statement 6 16 37.5
branch 0 4 0.0
condition n/a
subroutine 2 4 50.0
pod 0 2 0.0
total 8 26 30.7


line stmt bran cond sub pod time code
1             package # hide from PAUSE
2             DBIx::Class::CDBICompat::GetSet;
3              
4 2     2   1300 use strict;
  2         5  
  2         62  
5 2     2   11 use warnings;
  2         4  
  2         386  
6              
7             #use base qw/Class::Accessor/;
8              
9             sub get {
10 0     0 0   my ($self, @cols) = @_;
11 0 0         if (@cols > 1) {
12 0           return map { $self->get_column($_) } @cols;
  0            
13             } else {
14 0           return $self->get_column($_[1]);
15             }
16             }
17              
18             sub set {
19 0     0 0   my($self, %data) = @_;
20              
21             # set_columns() is going to do a string comparison before setting.
22             # This breaks on DateTime objects (whose comparison is arguably broken)
23             # so we stringify anything first.
24 0           for my $key (keys %data) {
25 0 0         next unless ref $data{$key};
26 0           $data{$key} = "$data{$key}";
27             }
28              
29 0           return shift->set_columns(\%data);
30             }
31              
32             1;