Sha256: af9dbb8267cc3c579ec89ad4f7886587fa9f1c42e9b0d0448976ef10cf8b9e28

Contents?: true

Size: 871 Bytes

Versions: 17

Compression:

Stored size: 871 Bytes

Contents

require_relative 'mapping'
require_relative 'dict_mappings_builder'

module Immutabler
  module DSL
    class MappingsBuilder
      def initialize(mappings, &block)
        @mappings = mappings
        instance_eval(&block)
      end

      def map(origin_name, destination_name, options = {})
        @mappings << Mapping.new(origin_name.to_s, destination_name.to_s, options)
      end

      def array(origin_name, destination_name, type)
        options = {
          type: type.to_s,
          array: true
        }
        @mappings << Mapping.new(origin_name.to_s, destination_name.to_s, options)
      end

      def dict(origin_name, destination_name, &block)
        mapping = Mapping.new(origin_name.to_s, destination_name.to_s, dict: true)
        DictMappingsBuilder.new(mapping.dict_mappings, &block)
        @mappings << mapping
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
immutabler-0.2.6 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.2.5 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.2.4 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.2.3 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.2.2 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.2.1 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.2.0 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.9 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.8 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.7 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.6 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.5 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.4 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.3 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.2 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.1 lib/immutabler/dsl/mappings_builder.rb
immutabler-0.1.0 lib/immutabler/dsl/mappings_builder.rb