Class: Remap::Rule::Set

Inherits:
Concrete
  • Object
show all
Defined in:
lib/remap/rule/set.rb

Overview

Set path to a static value

Examples:

Set path [:a, :b] to value “C”

value = Remap::Static::Fixed.new(value: "a value")
set = Remap::Rule::Set.new(value: value, path: [:a, :b])
state = Remap::State.call("ANY VALUE")
set.call(state).fetch(:value) # => { a: { b: "a value" } }

Set path [:a, :b] to option :c

value = Remap::Static::Option.new(name: :c)
set = Remap::Rule::Set.new(value: value, path: [:a, :b])
state = Remap::State.call("ANY VALUE", options: { c: "C" })
set.call(state).fetch(:value) # => { a: { b: "C" } }

Instance Method Summary collapse

Instance Method Details

#callObject

See Also:



28
29
30
# File 'lib/remap/rule/set.rb', line 28

def call(...)
  rule.call(...).then(&path)
end

#pathPath::Output

Returns:



25
# File 'lib/remap/rule/set.rb', line 25

attribute :path, Path::Output

#valueStatic

Returns:



22
# File 'lib/remap/rule/set.rb', line 22

attribute :value, Static, alias: :rule