Class: Monolens::Object::Values
- Inherits:
-
Object
- Object
- Monolens::Object::Values
show all
- Includes:
- Lens
- Defined in:
- lib/monolens/stdlib/object/values.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
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/monolens/stdlib/object/values.rb', line 11
def call(arg, world = {})
is_hash!(arg, world)
lenses = option(:lenses)
result = arg.dup
arg.each_pair do |attr, value|
deeper(world, attr) do |w|
begin
result[attr] = lenses.call(value, w)
rescue Monolens::LensError => ex
strategy = option(:on_error, :fail)
handle_error(strategy, ex, result, attr, value, world)
end
end
end
result
end
|