Add update_or_create_related
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Relationship / Base.pm
index a8d3d3c..034e5cc 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 use base qw/DBIx::Class/;
 
-=head1 NAME 
+=head1 NAME
 
 DBIx::Class::Relationship::Base - Inter-table relationships
 
@@ -15,7 +15,7 @@ DBIx::Class::Relationship::Base - Inter-table relationships
 
 This class provides methods to describe the relationships between the
 tables in your database model. These are the "bare bones" relationships
-methods, for predefined ones, look in L<DBIx::Class::Relationship>. 
+methods, for predefined ones, look in L<DBIx::Class::Relationship>.
 
 =head1 METHODS
 
@@ -252,6 +252,21 @@ sub find_or_create_related {
   return $self->find_related(@_) || $self->create_related(@_);
 }
 
+=head2 update_or_create_related
+
+  my $updated_item = $obj->update_or_create_related('relname', \%col_data, \%attrs?);
+
+Update or create an item of a related class. See
+L<DBIx::Class::ResultSet/"update_or_create"> for details.
+
+=cut
+
+sub update_or_create_related {
+  my $self = shift;
+  my $rel = shift;
+  return $self->related_resultset($rel)->update_or_create(@_);
+}
+
 =head2 set_from_related
 
   $book->set_from_related('author', $author_obj);