Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-13 17:59:49 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-13 17:59:49 +0300
commitd806230f9f95a2d08253f6c534ba69d1b9a498ea (patch)
tree96b9c5158648ae6e16ccb85ca2c284d0d4c68034 /app/models/namespace.rb
parent5c06875c39c8b525db41e73560f8cb1746119dd9 (diff)
Add parents method to Namespace
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb25
1 files changed, 20 insertions, 5 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 464be910f5a..b3cefc01b99 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -163,11 +163,26 @@ class Namespace < ActiveRecord::Base
end
def full_name
- if parent
- parent.full_name + ' / ' + name
- else
- name
- end
+ @full_name ||=
+ if parent
+ parent.full_name + ' / ' + name
+ else
+ name
+ end
+ end
+
+ def parents
+ @parents ||=
+ begin
+ parents = []
+
+ if parent
+ parents << parent
+ parents += parent.parents
+ end
+
+ parents
+ end
end
private