diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-03-06 23:07:19 -0500 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2016-03-06 23:07:19 -0500 |
commit | 95b06a62c0db5f8c285a1d24fa1994e10c70ff27 (patch) | |
tree | 97932d8d2155de4c4d71bba06dff8fe0f7eeb09a /app/models/global_label.rb | |
parent | c91554de09cb2b19e1403fdf50f691004e6befdb (diff) | |
download | gitlab-ce-95b06a62c0db5f8c285a1d24fa1994e10c70ff27.tar.gz |
Updates from last code review.issue_13621_2
Diffstat (limited to 'app/models/global_label.rb')
-rw-r--r-- | app/models/global_label.rb | 7 |
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 |