Merge 'trunk' into 'sybase_mssql'
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / Copy.pm
CommitLineData
c0494fe1 1package # hide from PAUSE
2 DBIx::Class::CDBICompat::Copy;
3
4use strict;
5use warnings;
6
7use Carp;
8
d03c0706 9=head1 NAME
10
b24d86a1 11DBIx::Class::CDBICompat::Copy - Emulates Class::DBI->copy($new_id)
d03c0706 12
13=head1 SYNOPSIS
14
15See DBIx::Class::CDBICompat for directions for use.
16
17=head1 DESCRIPTION
18
19Emulates C<<Class::DBI->copy($new_id)>>.
20
21=cut
22
23
c0494fe1 24# CDBI's copy will take an id in addition to a hash ref.
25sub copy {
26 my($self, $arg) = @_;
27 return $self->next::method($arg) if ref $arg;
28
29 my @primary_columns = $self->primary_columns;
30 croak("Need hash-ref to edit copied column values")
31 if @primary_columns > 1;
32
33 return $self->next::method({ $primary_columns[0] => $arg });
34}
35
361;