[Bast-commits] r4649 -
DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Fri Jul 25 23:48:24 BST 2008
Author: rafl
Date: 2008-07-25 23:48:23 +0100 (Fri, 25 Jul 2008)
New Revision: 4649
Modified:
DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet/Multi.pm
Log:
Implement is_{root,branch,leaf}.
Modified: DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet/Multi.pm
===================================================================
--- DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet/Multi.pm 2008-07-25 22:48:16 UTC (rev 4648)
+++ DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet/Multi.pm 2008-07-25 22:48:23 UTC (rev 4649)
@@ -154,4 +154,26 @@
*search_related_rs = \&search_related;
}
+sub is_root {
+ my ($self) = @_;
+
+ return $self->get_column( $self->tree_columns->{left_column} ) == 1 ? 1 : 0;
+}
+
+sub is_leaf {
+ my ($self) = @_;
+
+ my ($left, $right) = map {
+ $self->get_column( $self->tree_columns->{"${_}_column"} )
+ } qw/left right/;
+
+ return $right - $left == 1 ? 1 : 0;
+}
+
+sub is_branch {
+ my ($self) = @_;
+
+ return !$self->is_leaf;
+}
+
1;
More information about the Bast-commits
mailing list