Class: DeferredException::Enumerator
- Inherits:
-
Object
- Object
- DeferredException::Enumerator
- Includes:
- Enumerable
- Defined in:
- lib/deferred_exception/enumerator.rb
Instance Attribute Summary collapse
-
#enumerator ⇒ Object
Returns the value of attribute enumerator.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #exceptions ⇒ Object
-
#initialize(enumerator) ⇒ Enumerator
constructor
A new instance of Enumerator.
Methods included from Enumerable
Constructor Details
#initialize(enumerator) ⇒ Enumerator
Returns a new instance of Enumerator.
7 8 9 |
# File 'lib/deferred_exception/enumerator.rb', line 7 def initialize(enumerator) self.enumerator = enumerator end |
Instance Attribute Details
#enumerator ⇒ Object
Returns the value of attribute enumerator.
5 6 7 |
# File 'lib/deferred_exception/enumerator.rb', line 5 def enumerator @enumerator end |
Instance Method Details
#each(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/deferred_exception/enumerator.rb', line 11 def each(&block) enumerator.each do |item| begin block.call(item) rescue StandardError => e exceptions.push(e) end end unless exceptions.empty? raise DeferredException::ExceptionSet.new(exceptions) end enumerator end |
#exceptions ⇒ Object
27 28 29 |
# File 'lib/deferred_exception/enumerator.rb', line 27 def exceptions @exceptions ||= [] end |