Class: ActiveRecordPgStuff::Relation::PivotResult
- Inherits:
-
Object
- Object
- ActiveRecordPgStuff::Relation::PivotResult
- Defined in:
- lib/activerecord_pg_stuff/relation/pivot.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #each_row(&block) ⇒ Object
-
#initialize(header_result, result) ⇒ PivotResult
constructor
A new instance of PivotResult.
Constructor Details
#initialize(header_result, result) ⇒ PivotResult
Returns a new instance of PivotResult.
7 8 9 10 |
# File 'lib/activerecord_pg_stuff/relation/pivot.rb', line 7 def initialize(header_result, result) @headers = [nil] + result_to_array(header_result).map(&:first) @rows = result_to_array(result) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/activerecord_pg_stuff/relation/pivot.rb', line 5 def headers @headers end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
5 6 7 |
# File 'lib/activerecord_pg_stuff/relation/pivot.rb', line 5 def rows @rows end |
Instance Method Details
#each_row(&block) ⇒ Object
12 13 14 |
# File 'lib/activerecord_pg_stuff/relation/pivot.rb', line 12 def each_row(&block) rows.each(&block) end |