Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / Constructor.pm
CommitLineData
c0e7b4e5 1package # hide from PAUSE
2 DBIx::Class::CDBICompat::Constructor;
a3018bd3 3
4use strict;
5use warnings;
6
8d73fcd4 7use base 'DBIx::Class::CDBICompat::ImaDBI';
8
2e424e0c 9use Carp;
8d73fcd4 10use DBIx::Class::_Util qw(quote_sub perlstring);
51ec0382 11use namespace::clean;
2e424e0c 12
13__PACKAGE__->set_sql(Retrieve => <<'');
14SELECT __ESSENTIAL__
15FROM __TABLE__
16WHERE %s
17
a3018bd3 18sub add_constructor {
2e424e0c 19 my ($class, $method, $fragment) = @_;
2e424e0c 20
8d73fcd4 21 croak("constructors needs a name") unless $method;
22
23 carp("$method already exists in $class") && return
24 if $class->can($method);
2e424e0c 25
8d73fcd4 26 quote_sub "${class}::${method}" => sprintf( <<'EOC', perlstring $fragment );
27 my $self = shift;
28 $self->sth_to_objects($self->sql_Retrieve(%s), \@_);
29EOC
a3018bd3 30}
31
321;