summaryrefslogtreecommitdiffstats
path: root/lib/redmine/nested_set
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-01-07 20:37:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-01-07 20:37:06 +0000
commitded15dfc802dec165784949d75ce70987cf5e409 (patch)
treecf027278b085b6495b1fbce379bf47c847e48ac2 /lib/redmine/nested_set
parentdaef6a8037ab66e1b2716ef42a197fc20228b237 (diff)
downloadredmine-ded15dfc802dec165784949d75ce70987cf5e409.tar.gz
redmine-ded15dfc802dec165784949d75ce70987cf5e409.zip
Moved Project#hierarchy to NestedSet::Traversing.
git-svn-id: http://svn.redmine.org/redmine/trunk@13843 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/nested_set')
-rw-r--r--lib/redmine/nested_set/traversing.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/redmine/nested_set/traversing.rb b/lib/redmine/nested_set/traversing.rb
index f1684c00b..5c58f60d6 100644
--- a/lib/redmine/nested_set/traversing.rb
+++ b/lib/redmine/nested_set/traversing.rb
@@ -111,6 +111,14 @@ module Redmine
def is_or_is_descendant_of?(other)
other == self || is_descendant_of?(other)
end
+
+ # Returns the ancestors, the element and its descendants
+ def hierarchy
+ nested_set_scope.where(
+ "#{self.class.table_name}.lft >= :lft AND #{self.class.table_name}.rgt <= :rgt" +
+ " OR #{self.class.table_name}.lft < :lft AND #{self.class.table_name}.rgt > :rgt",
+ {:lft => lft, :rgt => rgt})
+ end
end
end
end