Module: LabelDefinitions
- Defined in:
- lib/label_definitions.rb,
lib/label_definitions/label.rb,
lib/label_definitions/version.rb
Defined Under Namespace
Classes: Label
Constant Summary collapse
- VERSION =
'1.1.2'
Class Method Summary collapse
-
.add(label) ⇒ Object
Adds a label definition to the in-memory list.
- .all ⇒ Object
- .find(name) ⇒ Object
Class Method Details
.add(label) ⇒ Object
Adds a label definition to the in-memory list. Does not persist it.
21 22 23 |
# File 'lib/label_definitions.rb', line 21 def self.add(label) find(label.name) || (all << label) end |
.all ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/label_definitions.rb', line 7 def self.all @labels ||= begin load_definitions.reduce([]) do |labels, (name, definition)| symbolize_keys! definition labels << Label.new(definition.merge(name: name)) end end end |
.find(name) ⇒ Object
16 17 18 |
# File 'lib/label_definitions.rb', line 16 def self.find(name) all.detect { |label| label.name == name } end |