Sha256: d676efcde4dc778b098c83e82eea3d47dc238579ef43db4908482770b4b834c5

Contents?: true

Size: 759 Bytes

Versions: 30

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

class ReeMapper::BuildMapperStrategy
  include Ree::FnDSL

  fn :build_mapper_strategy

  OUTPUT_MAP = {
    string_key_hash: ReeMapper::StringKeyHashOutput,
    symbol_key_hash: ReeMapper::SymbolKeyHashOutput,
    object:          ReeMapper::ObjectOutput
  }.freeze

  contract(Kwargs[
    method:          Symbol,
    output:          Symbol,
    always_optional: Bool
  ] => ReeMapper::MapperStrategy).throws(ArgumentError)
  def call(method:, output:, always_optional: false)
    raise ArgumentError, 'invalid output' unless OUTPUT_MAP.key?(output)

    ReeMapper::MapperStrategy.new(
      method:          method,
      output:          OUTPUT_MAP.fetch(output).new,
      always_optional: always_optional
    )
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
ree_lib-1.0.30 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.29 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.28 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.27 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.26 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.24 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.23 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.22 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.21 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.20 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.19 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.18 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.17 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.16 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.15 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.14 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.13 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.12 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.11 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb
ree_lib-1.0.10 lib/ree_lib/packages/ree_mapper/package/ree_mapper/functions/build_mapper_strategy.rb