Class: Botz::Looper
- Inherits:
-
Object
- Object
- Botz::Looper
- Defined in:
- lib/botz/looper.rb
Overview
looper
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(resource, binder, loop_block) ⇒ Looper
constructor
A new instance of Looper.
Constructor Details
#initialize(resource, binder, loop_block) ⇒ Looper
Returns a new instance of Looper.
7 8 9 10 11 |
# File 'lib/botz/looper.rb', line 7 def initialize(resource, binder, loop_block) @resource = resource @binder = binder @loop_block = loop_block end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/botz/looper.rb', line 13 def call yielder = lambda do |element| result = @binder.new(element).result fail "#{element}\n\n#{result.errors.}" if result.invalid? yield result end @loop_block.call(@resource, yielder) end |