Sha256: 9a2377d8ad2f0cb190940a17e610654360a14f38ad5e1fa19432fadc8980b1ab

Contents?: true

Size: 641 Bytes

Versions: 11

Compression:

Stored size: 641 Bytes

Contents

require 'rom/support/registry'

module ROM
  # @private
  class MapperRegistry < Registry
    # @api private
    def []=(name, mapper)
      elements[name] = mapper
    end

    # @api private
    def [](name)
      elements.fetch(name) { raise(MapperMissingError, name) }
    end

    # @api private
    def key?(name)
      elements.key?(name)
    end

    # @api private
    def by_path(path)
      elements.fetch(paths(path).detect { |name| elements.key?(name) }) {
        raise(MapperMissingError, path)
      }
    end

    private

    # @api private
    def paths(path)
      path.split('.').map(&:to_sym).reverse
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rom-2.0.2 lib/rom/mapper_registry.rb
rom-2.0.1 lib/rom/mapper_registry.rb
rom-2.0.0 lib/rom/mapper_registry.rb
rom-1.0.0 lib/rom/mapper_registry.rb
rom-1.0.0.rc1 lib/rom/mapper_registry.rb
rom-1.0.0.beta2 lib/rom/mapper_registry.rb
rom-1.0.0.beta1 lib/rom/mapper_registry.rb
rom-0.9.1 lib/rom/mapper_registry.rb
rom-0.9.0 lib/rom/mapper_registry.rb
rom-0.9.0.rc1 lib/rom/mapper_registry.rb
rom-0.9.0.beta1 lib/rom/mapper_registry.rb