summaryrefslogtreecommitdiffstats
path: root/app/models/project.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 40898a34e..4b0236b37 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -493,6 +493,15 @@ class Project < ActiveRecord::Base
enabled_modules.clear
end
end
+
+ # Returns an array of projects that are in this project's hierarchy
+ #
+ # Example: parents, children, siblings
+ def hierarchy
+ parents = project.self_and_ancestors || []
+ descendants = project.descendants || []
+ project_hierarchy = parents | descendants # Set union
+ end
# Returns an auto-generated project identifier based on the last identifier used
def self.next_identifier