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
10 11 12 |
# File 'lib/tdc/generators/catalog_entries.rb', line 10 def add_catalog_entry(tag, entry) send(:"#{tag}=", entry) end |
#empty? ⇒ Boolean
14 15 16 |
# File 'lib/tdc/generators/catalog_entries.rb', line 14 def empty? to_h.empty? end |
#entries ⇒ Object
18 19 20 |
# File 'lib/tdc/generators/catalog_entries.rb', line 18 def entries to_h.keys end |
#first ⇒ Object
22 23 24 |
# File 'lib/tdc/generators/catalog_entries.rb', line 22 def first to_h.first&.second end |
#single_entry ⇒ Object
26 27 28 29 30 |
# File 'lib/tdc/generators/catalog_entries.rb', line 26 def single_entry raise Tdc::FatalError, "There is more than one entry" if to_h.many? first end |