Sha256: 7f46f20f18b4be1fc26e8c2174ea6c8308e2317ead49edd916108326027cdb4d

Contents?: true

Size: 392 Bytes

Versions: 5

Compression:

Stored size: 392 Bytes

Contents

require 'semlogr/error'

module Semlogr
  class ComponentRegistry
    @mappings = {}

    def self.register(type, mapping)
      (@mappings[type] ||= {}).update(mapping)
    end

    def self.resolve(type, key, *params)
      mapping = @mappings[type] && @mappings[type][key]
      raise ComponentNotRegisteredError.new(type, key) unless mapping

      mapping.new(*params)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
semlogr-0.3.0 lib/semlogr/component_registry.rb
semlogr-0.2.3 lib/semlogr/component_registry.rb
semlogr-0.2.2 lib/semlogr/component_registry.rb
semlogr-0.2.1 lib/semlogr/component_registry.rb
semlogr-0.2.0 lib/semlogr/component_registry.rb