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