Sha256: acc87954572b758e0a20fe7029b2952a36a548538ccd6d3c6b35e19d91162033

Contents?: true

Size: 617 Bytes

Versions: 1

Compression:

Stored size: 617 Bytes

Contents

module Streamingly

  class SerDeIterable
    def initialize(iterable, error_handler = nil)
      @iterable = iterable
      @error_handler = error_handler
      @error_callback_defined = @error_handler &&
                                @error_handler.respond_to?(:on_error)
    end

    def each
      @iterable.each do |line|
        begin
          yield Streamingly::SerDe.from_tabbed_csv(line)
        rescue => error
          if @error_callback_defined
            @error_handler.send(:on_error, error, line: line)
          else
            raise error
          end
        end
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
streamingly-0.2.6 lib/streamingly/serde_iterable.rb