Sha256: 11f8f8963abc1105baffc97f85b3a1279ee246204b5994ce378ada3d96867455

Contents?: true

Size: 468 Bytes

Versions: 3

Compression:

Stored size: 468 Bytes

Contents

module AssemblyLine
  module Registry
    extend self

    def add(name, block)
      constructors[name] = Constructor.new(name, block)
    end

    def list
      constructors.keys.dup
    end

    def locate(name)
      constructors[name] || raise(ArgumentError, "AssemblyLine could not find definition for: '#{name.inspect}'")
    end

    def clear
      constructors.clear
    end

    protected

    def constructors
      @constructors ||= {}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
assembly_line-0.2.1 lib/assembly_line/registry.rb
assembly_line-0.2.0 lib/assembly_line/registry.rb
assembly_line-0.1.0 lib/assembly_line/registry.rb