Module: Remap::State

Includes:
Dry::Core::Constants
Defined in:
lib/remap/state.rb,
lib/remap/state/schema.rb,
lib/remap/state/extension.rb

Overview

Represents the current state of a mapping

Defined Under Namespace

Modules: Extension Classes: Dummy

Constant Summary collapse

Schema =
Dry::Schema.define do
  required(:input)

  required(:mapper).filled(Remap::Types::Mapper)
  required(:notices).array(Types.Instance(Notice))
  required(:options).value(:hash)
  required(:path).array(Types::Key)

  required(:ids).array(Types::ID)
  optional(:id).filled(Types::ID)

  required(:fatal_ids).array(Types::ID)
  optional(:fatal_id).filled(Types::ID)

  optional(:index).filled(:integer)
  optional(:element).filled
  optional(:key).filled

  optional(:scope)
  optional(:value)
end

Class Method Summary collapse

Class Method Details

.call(value, mapper: Dummy, options: EMPTY_HASH) ⇒ Hash

Creates a valid state

Parameters:

  • value (Any)

    Internal state value

  • mapper (Hash) (defaults to: Dummy)

    a customizable set of options

  • options (Hash) (defaults to: EMPTY_HASH)

    a customizable set of options

Options Hash (mapper:):

  • Mapper (Mapper::Class)

    class

Options Hash (options:):

  • Mapper (Hash)

    options / arguments

Returns:

  • (Hash)

    A valid state



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/remap/state.rb', line 32

def self.call(value, mapper: Dummy, options: EMPTY_HASH)
  {
    fatal_ids: [],
    notices: [],
    path: [],
    options: options,
    ids: [],
    mapper: mapper,
    values: value,
    value: value,
    input: value
  }._
end