Class: RDBI::Result::Driver::Struct

Inherits:
RDBI::Result::Driver show all
Defined in:
lib/rdbi/result.rb

Overview

Yields Struct objects instead of arrays for the rows. What this means is that you will recieve a single array of Structs, each struct representing a row of the database.

example:

results = dbh.execute("select foo, bar from my_table").fetch(:all, :Struct)

results[0].foo        # first row, foo column
results[10].bar       # 11th row, bar column

Instance Method Summary collapse

Constructor Details

#initialize(result, *args) ⇒ Struct

Returns a new instance of Struct.



420
421
422
# File 'lib/rdbi/result.rb', line 420

def initialize(result, *args)
  super
end

Instance Method Details

#format_multiple_rows(raw_rows) ⇒ Object



428
429
430
# File 'lib/rdbi/result.rb', line 428

def format_multiple_rows(raw_rows)
  super.collect { |row| struct_klass.new(*row) }
end

#format_single_row(raw) ⇒ Object



424
425
426
# File 'lib/rdbi/result.rb', line 424

def format_single_row(raw)
  struct_klass.new(*super)
end