Class: GlobalLabel

Inherits:
Object
  • Object
show all
Defined in:
app/models/global_label.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, labels) ⇒ GlobalLabel

Returns a new instance of GlobalLabel


15
16
17
18
19
# File 'app/models/global_label.rb', line 15

def initialize(title, labels)
  @title = title
  @labels = labels
  @first_label = labels.find { |lbl| lbl.description.present? } || labels.first
end

Instance Attribute Details

#labelsObject

Returns the value of attribute labels


2
3
4
# File 'app/models/global_label.rb', line 2

def labels
  @labels
end

#titleObject

Returns the value of attribute title


2
3
4
# File 'app/models/global_label.rb', line 2

def title
  @title
end

Class Method Details

.build_collection(labels) ⇒ Object


7
8
9
10
11
12
13
# File 'app/models/global_label.rb', line 7

def self.build_collection(labels)
  labels = labels.group_by(&:title)

  labels.map do |title, labels|
    new(title, labels)
  end
end