Sha256: 5b20b8976667609945eb3ccf3d99059af3251d1f6bb75ff41be844c333f2712f

Contents?: true

Size: 484 Bytes

Versions: 3

Compression:

Stored size: 484 Bytes

Contents

module Makers
  class Definitions

    def find(id)
      if registry.has_key?(id)
        registry[id]
      else
        raise "Definition #{id} not found"
      end
    end

    def add(ids, *args)
      maker = Maker.new(*args)
      ids.each do |id|
        if registry.has_key?(id)
          raise "Maker #{id} already registered"
        else
          registry[id] = maker
        end
      end
    end

    private

    def registry
      @registry ||= {}
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
makers-5.1.0 lib/makers/definitions.rb
makers-4.0.0.4 lib/makers/definitions.rb
makers-4.0.0.3 lib/makers/definitions.rb