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:
authorRubén Dávila <rdavila84@gmail.com>2016-03-07 07:07:19 +0300
committerRubén Dávila <rdavila84@gmail.com>2016-03-07 07:07:19 +0300
commit95b06a62c0db5f8c285a1d24fa1994e10c70ff27 (patch)
tree97932d8d2155de4c4d71bba06dff8fe0f7eeb09a /app/models/global_label.rb
parentc91554de09cb2b19e1403fdf50f691004e6befdb (diff)
Updates from last code review.
Diffstat (limited to 'app/models/global_label.rb')
-rw-r--r--app/models/global_label.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/global_label.rb b/app/models/global_label.rb
index 0171f7d54b7..ddd4bad5c21 100644
--- a/app/models/global_label.rb
+++ b/app/models/global_label.rb
@@ -2,16 +2,19 @@ class GlobalLabel
attr_accessor :title, :labels
alias_attribute :name, :title
+ delegate :color, :description, to: :@first_label
+
def self.build_collection(labels)
labels = labels.group_by(&:title)
- labels.map do |title, label|
- new(title, label)
+ labels.map do |title, labels|
+ new(title, labels)
end
end
def initialize(title, labels)
@title = title
@labels = labels
+ @first_label = labels.find { |lbl| lbl.description.present? } || labels.first
end
end