From: Arthur Axel 'fREW' Schmidt Date: Tue, 15 May 2012 13:55:59 +0000 (-0500) Subject: add link instead of duplicating add_relationship docs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ee64ef5c35d6e7389c9c11ea5c037d8e3fc70a17;p=dbsrgits%2FDBIx-Class.git add link instead of duplicating add_relationship docs --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 8bf7d67..062d1f1 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1156,80 +1156,7 @@ sub storage { shift->schema->storage; } =head2 add_relationship -=over 4 - -=item Arguments: $relname, $related_source_name, \%cond, [ \%attrs ] - -=item Return value: 1/true if it succeeded - -=back - - $source->add_relationship('relname', 'related_source', $cond, $attrs); - -L describes a series of methods which -create pre-defined useful types of relationships. Look there first -before using this method directly. - -The relationship name can be arbitrary, but must be unique for each -relationship attached to this result source. 'related_source' should -be the name with which the related result source was registered with -the current schema. For example: - - $schema->source('Book')->add_relationship('reviews', 'Review', { - 'foreign.book_id' => 'self.id', - }); - -The condition C<$cond> needs to be an L-style -representation of the join between the tables. For example, if you're -creating a relation from Author to Book, - - { 'foreign.author_id' => 'self.id' } - -will result in the JOIN clause - - author me JOIN book foreign ON foreign.author_id = me.id - -You can specify as many foreign => self mappings as necessary. - -Valid attributes are as follows: - -=over 4 - -=item join_type - -Explicitly specifies the type of join to use in the relationship. Any -SQL join type is valid, e.g. C or C. It will be placed in -the SQL command immediately before C. - -=item proxy - -An arrayref containing a list of accessors in the foreign class to proxy in -the main class. If, for example, you do the following: - - CD->might_have(liner_notes => 'LinerNotes', undef, { - proxy => [ qw/notes/ ], - }); - -Then, assuming LinerNotes has an accessor named notes, you can do: - - my $cd = CD->find(1); - # set notes -- LinerNotes object is created if it doesn't exist - $cd->notes('Notes go here'); - -=item accessor - -Specifies the type of accessor that should be created for the -relationship. Valid values are C (for when there is only a single -related object), C (when there can be many), and C (for -when there is a single related object, but you also want the relationship -accessor to double as a column accessor). For C accessors, an -add_to_* method is also created, which calls C for the -relationship. - -=back - -Throws an exception if the condition is improperly supplied, or cannot -be resolved. +See L =cut