Class: Remap::Path::Output

Inherits:
Unit
  • Object
show all
Defined in:
lib/remap/path/output.rb

Overview

Sets the value to a given path

Examples:

Maps “A” to { a: { b: { c: “A” } } }

state = Remap::State.call("A")
result = Remap::Path::Output.new([:a, :b, :c]).call(state)

result.fetch(:value) # => { a: { b: { c: "A" } } }

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ State

Returns:



36
37
38
39
40
41
42
43
44
# File 'lib/remap/path/output.rb', line 36

def call(state)
  mapped = selectors.map do |selector|
    selector.call(state)
  end

  state.fmap do |value|
    mapped.hide(value)
  end
end