Sha256: 75b0084bb195f9917069b801f9680060bc0ba212b4cb2718dcfa83e6348d96bc
Contents?: true
Size: 992 Bytes
Versions: 12
Compression:
Stored size: 992 Bytes
Contents
# frozen_string_literal: true require 'dry/core/class_builder' module ROM class Mapper # Setup DSL-specific mapper extensions # # @private class Builder # Generate a mapper subclass # # This is used by Setup#mappers DSL # # @api private def self.build_class(name, mapper_registry, options = EMPTY_HASH, &block) class_name = "ROM::Mapper[#{name}]" parent = options[:parent] inherit_header = options.fetch(:inherit_header) { ROM::Mapper.inherit_header } parent_class = if parent mapper_registry.detect { |klass| klass.relation == parent } else ROM::Mapper end Dry::Core::ClassBuilder.new(name: class_name, parent: parent_class).call do |klass| klass.register_as(name) klass.relation(name) klass.inherit_header(inherit_header) klass.class_eval(&block) if block end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems