Class: Monolens::Array::Map
- Inherits:
-
Object
- Object
- Monolens::Array::Map
show all
- Includes:
- Lens
- Defined in:
- lib/monolens/stdlib/array/map.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/array/map.rb', line 11
def call(arg, world = {})
is_array!(arg, world)
lenses = option(:lenses)
result = []
arg.each_with_index do |member, i|
deeper(world, i) do |w|
begin
result << lenses.call(member, w)
rescue Monolens::LensError => ex
strategy = option(:on_error, :fail)
handle_error(strategy, member, ex, result, world)
end
end
end
result
end
|