Class: PGlite::Result
- Inherits:
-
Object
- Object
- PGlite::Result
- Includes:
- Enumerable
- Defined in:
- lib/pglite/result.rb
Instance Attribute Summary collapse
-
#res ⇒ Object
readonly
Returns the value of attribute res.
Instance Method Summary collapse
-
#check ⇒ Object
Rails calls result.check to raise on server errors; already handled upstream.
- #clear ⇒ Object
- #cmd_tuples ⇒ Object
- #each ⇒ Object
- #fields ⇒ Object
- #fmod(index) ⇒ Object
- #ftype(index) ⇒ Object
-
#initialize(res) ⇒ Result
constructor
A wrapper for a result object from Oxide.
- #map_types!(map) ⇒ Object
- #ntuples ⇒ Object
-
#result_status ⇒ Object
Rails' get_result loop compares against PG::PGRES_FATAL_ERROR; pglite raises PG::Error at query time, so any result reaching here is non-fatal.
- #values ⇒ Object
Constructor Details
#initialize(res) ⇒ Result
A wrapper for a result object from Oxide
8 9 10 |
# File 'lib/pglite/result.rb', line 8 def initialize(res) @res = res end |
Instance Attribute Details
#res ⇒ Object (readonly)
Returns the value of attribute res.
5 6 7 |
# File 'lib/pglite/result.rb', line 5 def res @res end |
Instance Method Details
#check ⇒ Object
Rails calls result.check to raise on server errors; already handled upstream.
33 |
# File 'lib/pglite/result.rb', line 33 def check = self |
#clear ⇒ Object
35 36 |
# File 'lib/pglite/result.rb', line 35 def clear end |
#cmd_tuples ⇒ Object
24 |
# File 'lib/pglite/result.rb', line 24 def cmd_tuples = res.row_count |
#each ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pglite/result.rb', line 40 def each return to_enum(:each) unless block_given? columns = fields res.rows.each do |res_row| row = {} columns.each.with_index do |col, i| value = res_row[i] row[col] = value end yield row end end |
#fields ⇒ Object
18 |
# File 'lib/pglite/result.rb', line 18 def fields = res.columns.map(&:name) |
#fmod(index) ⇒ Object
22 |
# File 'lib/pglite/result.rb', line 22 def fmod(index) = res.columns[index].type_modifier |
#ftype(index) ⇒ Object
20 |
# File 'lib/pglite/result.rb', line 20 def ftype(index) = res.columns[index].oid |
#map_types!(map) ⇒ Object
12 13 14 |
# File 'lib/pglite/result.rb', line 12 def map_types!(map) self end |
#ntuples ⇒ Object
26 |
# File 'lib/pglite/result.rb', line 26 def ntuples = res.row_count |
#result_status ⇒ Object
Rails' get_result loop compares against PG::PGRES_FATAL_ERROR; pglite raises PG::Error at query time, so any result reaching here is non-fatal.
30 |
# File 'lib/pglite/result.rb', line 30 def result_status = PG::PGRES_TUPLES_OK |
#values ⇒ Object
16 |
# File 'lib/pglite/result.rb', line 16 def values = res.rows |