Class: Remap::Static::Option

Inherits:
Concrete
  • Object
show all
Defined in:
lib/remap/static/option.rb

Overview

Maps a mapper argument to a path

Examples:

Maps a mapper argument to a path

class Mapper < Remap::Base
  option :name

  define do
    set :nickname, to: option(:name)
  end
end

Mapper.call({}, name: "John") # => { nickname: "John" }

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ State

Selects #name from state

Parameters:

Returns:



28
29
30
31
32
33
34
# File 'lib/remap/static/option.rb', line 28

def call(state)
  value = state.options.fetch(name) do
    raise ArgumentError, "Option [%s] not found" % [name], backtrace
  end

  state.set(value)
end

#nameSymbol

Returns:

  • (Symbol)


21
# File 'lib/remap/static/option.rb', line 21

attribute :name, Symbol