Class: Terrazine::Result
Overview
inheritance from row for delegation methods to first row… may be method missing?
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(result, options) ⇒ Result
constructor
TODO: as arguments keys, values and options? Future support of another db? arguments - PG::Result instance and hash of options.
- #pg_result ⇒ Object
- #present(o = {}) ⇒ Object
-
#values ⇒ Object
ResultRow inheritance support.
Methods inherited from Row
#method_missing, #respond_to_missing?, #to_h
Constructor Details
#initialize(result, options) ⇒ Result
TODO: as arguments keys, values and options? Future support of another db? arguments - PG::Result instance and hash of options
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/terrazine/result.rb', line 41 def initialize(result, ) # how another db parsing data? TypeMap.update(result, [:types]) if [:types] @options = @fields = result.fields @rows = [] result.each_row { |i| @rows << Row.new(self, i) } result.clear # they advise to clear it, but maybe better to use it until presenter? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Terrazine::Row
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
37 38 39 |
# File 'lib/terrazine/result.rb', line 37 def fields @fields end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
37 38 39 |
# File 'lib/terrazine/result.rb', line 37 def @options end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
37 38 39 |
# File 'lib/terrazine/result.rb', line 37 def rows @rows end |
Instance Method Details
#pg_result ⇒ Object
62 63 64 |
# File 'lib/terrazine/result.rb', line 62 def pg_result self end |
#present(o = {}) ⇒ Object
52 53 54 55 |
# File 'lib/terrazine/result.rb', line 52 def present(o = {}) = @options[:presenter_options] ? o.merge(@options[:presenter_options]) : o Presenter.present(self, ) end |
#values ⇒ Object
ResultRow inheritance support
58 59 60 |
# File 'lib/terrazine/result.rb', line 58 def values first&.values end |