File Coverage

blib/lib/DBIx/Class/CDBICompat/Copy.pm
Criterion Covered Total %
statement 15 20 75.0
branch 0 4 0.0
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 20 31 64.5


line stmt bran cond sub pod time code
1             package # hide from PAUSE
2             DBIx::Class::CDBICompat::Copy;
3              
4 2     2   2445 use strict;
  2         4  
  2         50  
5 2     2   9 use warnings;
  2         4  
  2         44  
6              
7 2     2   9 use base 'DBIx::Class';
  2         5  
  2         167  
8              
9 2     2   11 use Carp;
  2         4  
  2         102  
10 2     2   11 use namespace::clean;
  2         13  
  2         11  
11              
12             =head1 NAME
13              
14             DBIx::Class::CDBICompat::Copy - Emulates Class::DBI->copy($new_id)
15              
16             =head1 SYNOPSIS
17              
18             See DBIx::Class::CDBICompat for usage directions.
19              
20             =head1 DESCRIPTION
21              
22             Emulates C<copy($new_id)>>.
23              
24             =cut
25              
26              
27             # CDBI's copy will take an id in addition to a hash ref.
28             sub copy {
29 0     0 0   my($self, $arg) = @_;
30 0 0         return $self->next::method($arg) if ref $arg;
31              
32 0           my @primary_columns = $self->primary_columns;
33 0 0         croak("Need hash-ref to edit copied column values")
34             if @primary_columns > 1;
35              
36 0           return $self->next::method({ $primary_columns[0] => $arg });
37             }
38              
39             =head1 FURTHER QUESTIONS?
40              
41             Check the list of L.
42              
43             =head1 COPYRIGHT AND LICENSE
44              
45             This module is free software L
46             by the L. You can
47             redistribute it and/or modify it under the same terms as the
48             L.
49              
50             =cut
51              
52             1;