1 package DBIx::Class::CDBICompat::HasA;
7 my ($self, $col, $f_class, %args) = @_;
8 $self->throw_exception( "No such column ${col}" ) unless $self->has_column($col);
9 eval "require $f_class";
10 if ($args{'inflate'} || $args{'deflate'}) { # Non-database has_a
11 if (!ref $args{'inflate'}) {
12 my $meth = $args{'inflate'};
13 $args{'inflate'} = sub { $f_class->$meth(shift); };
15 if (!ref $args{'deflate'}) {
16 my $meth = $args{'deflate'};
17 $args{'deflate'} = sub { shift->$meth; };
19 $self->inflate_column($col, \%args);
23 $self->belongs_to($col, $f_class);
30 if (@_ > 1 && ref $_[$#_] eq 'HASH') {
31 $attrs = { %{ pop(@_) } };
33 my $where = (@_ ? ((@_ == 1) ? ((ref $_[0] eq "HASH") ? { %{+shift} } : shift)
36 if (ref $where eq 'HASH') {
37 foreach my $key (keys %$where) { # has_a deflation hack
38 $where->{$key} = ''.$where->{$key}
39 if eval { $where->{$key}->isa('DBIx::Class') };
42 $self->next::method($where, $attrs);