Sha256: ca42a7fc04a84732f9668d76c3b865e1f0c6f548f2c2524de8472d698412543b

Contents?: true

Size: 599 Bytes

Versions: 6

Compression:

Stored size: 599 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 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

6 entries across 6 versions & 1 rubygems

Version Path
tdc-0.4.4.1 lib/tdc/generators/catalog_entries.rb
tdc-0.4.4 lib/tdc/generators/catalog_entries.rb
tdc-0.4.3.1 lib/tdc/generators/catalog_entries.rb
tdc-0.4.3 lib/tdc/generators/catalog_entries.rb
tdc-0.4.2 lib/tdc/generators/catalog_entries.rb
tdc-0.4.1 lib/tdc/generators/catalog_entries.rb