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