Sha256: a8afbd7c0f2c43c949a96622f1625daa19b499e17e4ad161c7c9324214c1d809

Contents?: true

Size: 646 Bytes

Versions: 7

Compression:

Stored size: 646 Bytes

Contents

module Tdc
  module Generators
    #
    # 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.
    #
    class CatalogEntries < OpenStruct
      def add_catalog_entry(tag, entry)
        send("#{tag}=", entry)
      end

      def empty?
        to_h.empty?
      end

      def entries
        to_h.keys
      end

      def first
        to_h.first&.second
      end

      def single_entry
        raise Tdc::FatalError, "There is more than one entry" if to_h.many?

        first
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tdc-0.6.2 lib/tdc/generators/catalog_entries.rb
tdc-0.6.1 lib/tdc/generators/catalog_entries.rb
tdc-0.6.0 lib/tdc/generators/catalog_entries.rb
tdc-0.5.0 lib/tdc/generators/catalog_entries.rb
tdc-0.4.7 lib/tdc/generators/catalog_entries.rb
tdc-0.4.6.1 lib/tdc/generators/catalog_entries.rb
tdc-0.4.6 lib/tdc/generators/catalog_entries.rb