Class: ActiveRecordPgStuff::Relation::PivotResult

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_pg_stuff/relation/pivot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/activerecord_pg_stuff/relation/pivot.rb', line 5

def headers
  @headers
end

#rowsObject (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