Class: Monolens::Core::Mapping

Inherits:
Object
  • Object
show all
Includes:
Lens
Defined in:
lib/monolens/core/mapping.rb

Instance Attribute Summary

Attributes included from Lens

#options

Instance Method Summary collapse

Methods included from Lens

#fetch_on, #initialize, #is_array!, #is_enumerable!, #is_hash!, #is_string!, #option

Instance Method Details

#call(arg, *rest) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/monolens/core/mapping.rb', line 6

def call(arg, *rest)
  option(:values, {}).fetch(arg) do
    raise LensError if option(:fail_if_missing)

    option(:default)
  end
end