Sha256: 7682e06edff6c25b5e737fbfd7c39ecb5672f92f1ee4aa75b4a906c31199ec6a
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require "dry/core/memoizable" require "dry/effects" require "rom/constants" require "rom/cache" require "rom/command_compiler" require "rom/mapper_compiler" module ROM # @api private class Inferrer include Dry::Core::Memoizable include Dry::Effects::Reader(:registry) attr_reader :cache, :config # @api private def initialize @cache = Cache.new end # @api private def call(ast, type, **opts) compiler(type, **opts).then do |compiler| case type when :mappers compiler.(ast) when :commands compiler.(*ast) # TODO: unify this end end end # @api private memoize def compiler(type, adapter:) case type when :mappers # TODO: move this to config adapter_ns = ROM.adapters[adapter] || ROM klass = if adapter_ns.const_defined?(:MapperCompiler) adapter_ns::MapperCompiler else MapperCompiler end klass.new(cache: cache) when :commands CommandCompiler.new(cache: cache.namespaced(:commands), registry: registry) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-6.0.0.alpha1 | lib/rom/inferrer.rb |