Class: Monolens::Core::Mapping
- Inherits:
-
Object
- Object
- Monolens::Core::Mapping
show all
- Includes:
- Lens
- Defined in:
- lib/monolens/stdlib/core/mapping.rb
Instance Attribute Summary
Attributes included from Lens
#options
Instance Method Summary
collapse
Methods included from Lens
#fail!, included, #initialize
#fetch_on
Instance Method Details
#call(arg, world = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/monolens/stdlib/core/mapping.rb', line 15
def call(arg, world = {})
original_arg = arg
if key_hash = option(:key_hash, nil)
arg = key_hash.call(arg, world)
end
option(:defn, option(:values, {})).fetch(arg) do
on_missing(original_arg, world)
end
end
|