Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / Relationships.pm
index 90ce39b..7b08d07 100644 (file)
@@ -128,7 +128,12 @@ sub has_many {
   );
 
   if (@f_method) {
-    quote_sub "${class}::${rel}", sprintf( <<'EOC', perlstring $rel), { '$rf' => \sub { my $o = shift; $o = $o->$_ for @f_method; $o } };
+    my @qsub_args = (
+      { '$rf' => \sub { my $o = shift; $o = $o->$_ for @f_method; $o } },
+      { attributes => [ 'DBIC_method_is_generated_from_resultsource_metadata' ] },
+    );
+
+    quote_sub "${class}::${rel}", sprintf( <<'EOC', perlstring $rel), @qsub_args;
       my $rs = shift->related_resultset(%s)->search_rs( @_);
       $rs->{attrs}{record_filter} = $rf;
       return (wantarray ? $rs->all : $rs);
@@ -194,7 +199,7 @@ sub meta_info {
 sub search {
   my $self = shift;
   my $attrs = {};
-  if (@_ > 1 && ref $_[$#_] eq 'HASH') {
+  if (@_ > 1 && ref $_[-1] eq 'HASH') {
     $attrs = { %{ pop(@_) } };
   }
   my $where = (@_ ? ((@_ == 1) ? ((ref $_[0] eq "HASH") ? { %{+shift} } : shift)
@@ -213,7 +218,10 @@ sub search {
 }
 
 sub new_related {
-  return shift->search_related(shift)->new_result(@_);
+  $_[0]->throw_exception("Calling new_related() as a class method is not supported")
+    unless length ref $_[0];
+
+  shift->next::method(@_);
 }
 
 =head1 FURTHER QUESTIONS?