Class: DB::Records
- Inherits:
-
Object
- Object
- DB::Records
- Defined in:
- lib/db/records.rb
Overview
A buffer of records.
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Class Method Summary collapse
Instance Method Summary collapse
- #freeze ⇒ Object
-
#initialize(columns, rows) ⇒ Records
constructor
A new instance of Records.
- #to_a ⇒ Object
Constructor Details
#initialize(columns, rows) ⇒ Records
Returns a new instance of Records.
18 19 20 21 |
# File 'lib/db/records.rb', line 18 def initialize(columns, rows) @columns = columns @rows = rows end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
32 33 34 |
# File 'lib/db/records.rb', line 32 def columns @columns end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
33 34 35 |
# File 'lib/db/records.rb', line 33 def rows @rows end |
Class Method Details
.wrap(result) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/db/records.rb', line 9 def self.wrap(result) # We want to avoid extra memory allocations when there are no columns: if result.field_count == 0 return nil end return self.new(result.field_names, result.to_a) end |
Instance Method Details
#freeze ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/db/records.rb', line 23 def freeze return self if frozen? @columns.freeze @rows.freeze super end |
#to_a ⇒ Object
35 36 37 |
# File 'lib/db/records.rb', line 35 def to_a @rows end |