Module: Pacer::Core::Route::IteratorBlockMixin

Defined in:
lib/pacer/support/iterator_mixins.rb

Overview

This mixin allows an iterator to be returned from methods that perform a transformation on the elements in their collection. Set the block property to the proc that does the transformation.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) graph

Returns the value of attribute graph



6
7
8
# File 'lib/pacer/support/iterator_mixins.rb', line 6

def graph
  @graph
end

Instance Method Details

- (Object) block=(block)

Set the block that does the transformation.



9
10
11
# File 'lib/pacer/support/iterator_mixins.rb', line 9

def block=(block)
  @block = block
end

- (Object) next



13
14
15
16
17
# File 'lib/pacer/support/iterator_mixins.rb', line 13

def next
  item = super
  item.graph ||= @graph
  @block.call(item)
end