Sha256: bef18c070524f2d3bbb053be45b8e63e057f16d66a925bf84e4742616b74a5d2

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'rom/mapper/builder'

module ROM
  module ConfigurationDSL
    # Mapper definition DSL used by Setup DSL
    #
    # @private
    class MapperDSL
      attr_reader :configuration, :mapper_classes, :defined_mappers

      # @api private
      def initialize(configuration, mapper_classes, block)
        @configuration = configuration
        @mapper_classes = mapper_classes
        @defined_mappers = []

        instance_exec(&block)

        @mapper_classes = @defined_mappers
      end

      # Define a mapper class
      #
      # @param [Symbol] name of the mapper
      # @param [Hash] options
      #
      # @return [Class]
      #
      # @api public
      def define(name, options = EMPTY_HASH, &block)
        @defined_mappers << Mapper::Builder.build_class(name, (@mapper_classes + @defined_mappers), options, &block)
        self
      end

      # TODO
      #
      # @api public
      def register(relation, mappers)
        configuration.register_mapper(relation => mappers)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rom-core-5.3.2 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.3.1 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.3.0 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.2.6 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.2.5 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.2.4 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.2.3 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.2.2 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.2.1 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.1.2 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.1.1 lib/rom/configuration_dsl/mapper_dsl.rb
rom-core-5.1.0 lib/rom/configuration_dsl/mapper_dsl.rb