Class: Monolens::Core::Chain
- Inherits:
-
Object
- Object
- Monolens::Core::Chain
- Includes:
- Lens
- Defined in:
- lib/monolens/stdlib/core/chain.rb
Instance Attribute Summary
Attributes included from Lens
Instance Method Summary collapse
- #call(arg, world = {}) ⇒ Object
-
#initialize(options, registry) ⇒ Chain
constructor
A new instance of Chain.
Methods included from Lens
Methods included from Lens::FetchSupport
Constructor Details
#initialize(options, registry) ⇒ Chain
Returns a new instance of Chain.
8 9 10 11 |
# File 'lib/monolens/stdlib/core/chain.rb', line 8 def initialize(, registry) super({}, registry) @lenses = .map{|l| lens(l) } end |
Instance Method Details
#call(arg, world = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/monolens/stdlib/core/chain.rb', line 13 def call(arg, world = {}) result = arg @lenses.each do |lens| done = false catch(:skip) do result = lens.call(result, world) done = true end break unless done end result end |