Sha256: 7cbfbb8134b2a6cbe0e1ea27d0881fdb66fc6e755d5aac1ff95f8f201182422b

Contents?: true

Size: 557 Bytes

Versions: 7

Compression:

Stored size: 557 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 single_entry
        raise Tdc::FatalError, "There is more than one entry" if to_h.many?

        to_h.first.second
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tdc-0.4.0 lib/tdc/generators/catalog_entries.rb
tdc-0.3.9 lib/tdc/generators/catalog_entries.rb
tdc-0.3.8 lib/tdc/generators/catalog_entries.rb
tdc-0.3.7 lib/tdc/generators/catalog_entries.rb
tdc-0.3.6.1 lib/tdc/generators/catalog_entries.rb
tdc-0.3.6 lib/tdc/generators/catalog_entries.rb
tdc-0.3.5 lib/tdc/generators/catalog_entries.rb