class DeferredException::Enumerator

Attributes

enumerator[RW]

Public Class Methods

new(enumerator) click to toggle source
# File lib/deferred_exception/enumerator.rb, line 7
def initialize(enumerator)
  self.enumerator = enumerator
end

Public Instance Methods

each(&block) click to toggle source
# 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() click to toggle source
# File lib/deferred_exception/enumerator.rb, line 27
def exceptions
  @exceptions ||= []
end