Introduce GOVERNANCE document and empty RESOLUTIONS file.
[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;
51ec0382 10use namespace::clean;
c0494fe1 11
d03c0706 12=head1 NAME
13
b24d86a1 14DBIx::Class::CDBICompat::Copy - Emulates Class::DBI->copy($new_id)
d03c0706 15
16=head1 SYNOPSIS
17
48580715 18See DBIx::Class::CDBICompat for usage directions.
d03c0706 19
20=head1 DESCRIPTION
21
22Emulates 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.
28sub 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
41Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
42
43=head1 COPYRIGHT AND LICENSE
44
45This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
46by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
47redistribute it and/or modify it under the same terms as the
48L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
49
50=cut
51
c0494fe1 521;