class DataObjects::Reader

Abstract class to read rows from a query result

Public Instance Methods

close() click to toggle source

Close the reader discarding any unread results.

# File lib/data_objects/reader.rb, line 18
def close
  raise NotImplementedError.new
end
each() { |row| ... } click to toggle source

Yield each row to the given block as a Hash

# File lib/data_objects/reader.rb, line 33
def each
  begin
    while next!
      row = {}
      fields.each_with_index { |field, index| row[field] = values[index] }
      yield row
    end
  ensure
    close
  end
  self
end
field_count() click to toggle source

Return the number of fields in the result set.

# File lib/data_objects/reader.rb, line 28
def field_count
  raise NotImplementedError.new
end
fields() click to toggle source

Return the array of field names

# File lib/data_objects/reader.rb, line 8
def fields
  raise NotImplementedError.new
end
next!() click to toggle source

Discard the current row (if any) and read the next one (returning true), or return nil if there is no further row.

# File lib/data_objects/reader.rb, line 23
def next!
  raise NotImplementedError.new
end
values() click to toggle source

Return the array of field values for the current row. Not legal after next! has returned false or before it's been called

# File lib/data_objects/reader.rb, line 13
def values
  raise NotImplementedError.new
end