Sha256: 06c41895774088f6bd043deb36a8c0be40c02e638cf9b44ad20a3441a30c7a01
Contents?: true
Size: 878 Bytes
Versions: 2
Compression:
Stored size: 878 Bytes
Contents
module ROM # @api private class ReaderBuilder DEFAULT_OPTIONS = { inherit_header: true }.freeze attr_reader :relations, :readers # @api private def initialize(relations) @relations = relations @readers = {} end # @api private def call(name, input_options = {}, &block) with_options(input_options) do |options| parent = relations[options.fetch(:parent) { name }] builder = MapperBuilder.new(name, parent, options) builder.instance_exec(&block) if block mapper = builder.call mappers = options[:parent] ? readers.fetch(parent.name).mappers : {} mappers[name] = mapper readers[name] = Reader.new(name, parent, mappers) unless options[:parent] end end private def with_options(options) yield(DEFAULT_OPTIONS.merge(options)) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rom-0.4.2 | lib/rom/reader_builder.rb |
rom-0.4.1 | lib/rom/reader_builder.rb |