Sha256: 1a37e89deac0f010e2fabcde18d9854f7e0b92c663dbdb49687872b5aa986cf5

Contents?: true

Size: 536 Bytes

Versions: 2

Compression:

Stored size: 536 Bytes

Contents

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 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

2 entries across 2 versions & 1 rubygems

Version Path
rom-0.6.0.beta2 lib/rom/mapper_registry.rb
rom-0.6.0.beta1 lib/rom/mapper_registry.rb