1 package # hide from PAUSE
2 DBIx::Class::CDBICompat::HasMany;
8 my ($class, $rel, $f_class, $f_key, $args) = @_;
12 if (ref $f_class eq 'ARRAY') {
13 ($f_class, @f_method) = @$f_class;
16 if (ref $f_key eq 'HASH' && !$args) { $args = $f_key; undef $f_key; };
19 if (delete $args->{no_cascade_delete}) {
20 $args->{cascade_delete} = 0;
23 if( !$f_key and !@f_method ) {
24 my $f_source = $f_class->result_source_instance;
25 ($f_key) = grep { $f_source->relationship_info($_)->{class} eq $class }
26 $f_source->relationships;
29 $class->next::method($rel, $f_class, $f_key, $args);
33 no warnings 'redefine';
34 my $post_proc = sub { my $o = shift; $o = $o->$_ for @f_method; $o; };
35 *{"${class}::${rel}"} =
37 my $rs = shift->search_related($rel => @_);
38 $rs->{attrs}{record_filter} = $post_proc;
39 return (wantarray ? $rs->all : $rs);