X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FBase.pm;h=e4d74888800a0d3e4f0d1a3c0fd6b3e3d3f66191;hb=412db1f428e95eeeac2a63f12b3c2d1ce1b3223a;hp=24c766df3a5f1b2adbd72c68d8795fc62e872842;hpb=3842b955be8f0d2e424d60c46afc3bc37ac33b97;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 24c766d..e4d7488 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -69,19 +69,13 @@ created, which calls C for the relationship. =back -=cut +=head2 register_relationship($relname, $rel_info) -sub add_relationship { - shift->result_source->add_relationship(@_); -} +Registers a relationship on the class -sub relationships { - shift->result_source->relationships(@_); -} +=cut -sub relationship_info { - shift->result_source->relationship_info(@_); -} +sub register_relationship { } =head2 search_related @@ -98,10 +92,10 @@ sub search_related { $attrs = { %{ pop(@_) } }; } my $rel_obj = $self->relationship_info($rel); - $self->throw( "No such relationship ${rel}" ) unless $rel_obj; + $self->throw_exception( "No such relationship ${rel}" ) unless $rel_obj; $attrs = { %{$rel_obj->{attrs} || {}}, %{$attrs || {}} }; - $self->throw( "Invalid query: @_" ) if (@_ > 1 && (@_ % 2 == 1)); + $self->throw_exception( "Invalid query: @_" ) if (@_ > 1 && (@_ % 2 == 1)); my $query = ((@_ > 1) ? {@_} : shift); my ($cond) = $self->result_source->resolve_condition($rel_obj->{cond}, $rel, $self); @@ -114,7 +108,7 @@ sub search_related { =head2 count_related - My::Table->count_related('relname', $cond, $attrs); + $obj->count_related('relname', $cond, $attrs); =cut @@ -178,20 +172,20 @@ sub find_or_create_related { sub set_from_related { my ($self, $rel, $f_obj) = @_; my $rel_obj = $self->relationship_info($rel); - $self->throw( "No such relationship ${rel}" ) unless $rel_obj; + $self->throw_exception( "No such relationship ${rel}" ) unless $rel_obj; my $cond = $rel_obj->{cond}; - $self->throw( "set_from_related can only handle a hash condition; the " + $self->throw_exception( "set_from_related can only handle a hash condition; the " ."condition for $rel is of type ".(ref $cond ? ref $cond : 'plain scalar')) unless ref $cond eq 'HASH'; my $f_class = $self->result_source->schema->class($rel_obj->{class}); - $self->throw( "Object $f_obj isn't a ".$f_class ) + $self->throw_exception( "Object $f_obj isn't a ".$f_class ) unless $f_obj->isa($f_class); foreach my $key (keys %$cond) { next if ref $cond->{$key}; # Skip literals and complex conditions - $self->throw("set_from_related can't handle $key as key") + $self->throw_exception("set_from_related can't handle $key as key") unless $key =~ m/^foreign\.([^\.]+)$/; my $val = $f_obj->get_column($1); - $self->throw("set_from_related can't handle ".$cond->{$key}." as value") + $self->throw_exception("set_from_related can't handle ".$cond->{$key}." as value") unless $cond->{$key} =~ m/^self\.([^\.]+)$/; $self->set_column($1 => $val); }