Class: Tdc::Generators::CatalogEntries
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Tdc::Generators::CatalogEntries
- Defined in:
- lib/tdc/generators/catalog_entries.rb
Overview
Knows how to contain arbitrary collections of model objects. As model instances are created by generators, the model instances are added to the current catalog as catalog entries.
Instance Method Summary collapse
- #add_catalog_entry(tag, entry) ⇒ Object
- #empty? ⇒ Boolean
- #entries ⇒ Object
- #first ⇒ Object
- #single_entry ⇒ Object
Instance Method Details
#add_catalog_entry(tag, entry) ⇒ Object
8 9 10 |
# File 'lib/tdc/generators/catalog_entries.rb', line 8 def add_catalog_entry(tag, entry) send(:"#{tag}=", entry) end |
#empty? ⇒ Boolean
12 13 14 |
# File 'lib/tdc/generators/catalog_entries.rb', line 12 def empty? to_h.empty? end |
#entries ⇒ Object
16 17 18 |
# File 'lib/tdc/generators/catalog_entries.rb', line 16 def entries to_h.keys end |
#first ⇒ Object
20 21 22 |
# File 'lib/tdc/generators/catalog_entries.rb', line 20 def first to_h.first&.second end |
#single_entry ⇒ Object
24 25 26 27 28 |
# File 'lib/tdc/generators/catalog_entries.rb', line 24 def single_entry raise Tdc::FatalError, "There is more than one entry" if to_h.many? first end |