Remove Class::Data::Inheritable and use CAG 'inherited' style accessors
[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
5e0eea35 7use base 'DBIx::Class';
8
c0494fe1 9use Carp;
10
d03c0706 11=head1 NAME
12
b24d86a1 13DBIx::Class::CDBICompat::Copy - Emulates Class::DBI->copy($new_id)
d03c0706 14
15=head1 SYNOPSIS
16
48580715 17See DBIx::Class::CDBICompat for usage directions.
d03c0706 18
19=head1 DESCRIPTION
20
21Emulates 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.
27sub 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
40Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
41
42=head1 COPYRIGHT AND LICENSE
43
44This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
45by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
46redistribute it and/or modify it under the same terms as the
47L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
48
49=cut
50
c0494fe1 511;