X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FTree%2FAdjacencyList.pm;h=e14875fe3e53a3cca2e11ac000ca6a75184ccae1;hb=ab184e4a4303cde87f3f585ec422f99898a915b4;hp=d913113dc05f17fe0b2625e8d8fc4a54a979701e;hpb=3c94ae56c4e2a8553d44944a111f479b0a87ff7d;p=dbsrgits%2FDBIx-Class-Tree.git diff --git a/lib/DBIx/Class/Tree/AdjacencyList.pm b/lib/DBIx/Class/Tree/AdjacencyList.pm index d913113..e14875f 100644 --- a/lib/DBIx/Class/Tree/AdjacencyList.pm +++ b/lib/DBIx/Class/Tree/AdjacencyList.pm @@ -66,11 +66,10 @@ stop you from having multiple root nodes. __PACKAGE__->parent_column('parent_id'); Declares the name of the column that contains the self-referential -ID which defines the parent row. Defaults to "parent_id". This -will create a has_many (children) and belongs_to (parent) -relationship. +ID which defines the parent row. This will create a has_many (children) +and belongs_to (parent) relationship. -This method also setups an additional has_many relationship called +This method also sets up an additional has_many relationship called parents which is useful when you want to treat an adjacency list as a DAG. @@ -114,7 +113,7 @@ And you execute: $b->parent( $d ); -Since D is a descendant of B then all of B's siblings get their parent +Since D is a descendant of B then all of D's siblings get their parent changed to A. Then B's parent is set to D. A @@ -310,10 +309,7 @@ Returns 1 if the object has no children, and 0 otherwise. sub is_leaf { my( $self ) = @_; - my $has_child = $self->result_source->resultset->search( - { $self->_parent_column => $self->id() }, - { limit => 1 } - )->count(); + my $has_child = $self->children_rs->count(); return $has_child ? 0 : 1; }