Commit | Line | Data |
---|---|---|
c0494fe1 | 1 | package # hide from PAUSE |
2 | DBIx::Class::CDBICompat::Copy; | |
3 | ||
4 | use strict; | |
5 | use warnings; | |
6 | ||
7 | use Carp; | |
8 | ||
9 | # CDBI's copy will take an id in addition to a hash ref. | |
10 | sub copy { | |
11 | my($self, $arg) = @_; | |
12 | return $self->next::method($arg) if ref $arg; | |
13 | ||
14 | my @primary_columns = $self->primary_columns; | |
15 | croak("Need hash-ref to edit copied column values") | |
16 | if @primary_columns > 1; | |
17 | ||
18 | return $self->next::method({ $primary_columns[0] => $arg }); | |
19 | } | |
20 | ||
21 | 1; |