Class: Rose::Proxy::Summary

Inherits:
Row
  • Object
show all
Defined in:
lib/rose/proxy.rb

Overview

This class is used by the DSL to collect summary attributes

Instance Attribute Summary collapse

Attributes inherited from Row

#attributes, #identity_attribute

Instance Method Summary collapse

Methods inherited from Row

#column, #identity, name_and_title

Constructor Details

#initialize(column_name) ⇒ Summary

Returns a new instance of Summary.



55
56
57
58
# File 'lib/rose/proxy.rb', line 55

def initialize(column_name)
  super()
  @column_name = column_name
end

Instance Attribute Details

#column_nameObject (readonly)

Returns the value of attribute column_name.



53
54
55
# File 'lib/rose/proxy.rb', line 53

def column_name
  @column_name
end

Instance Method Details

#on(table) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rose/proxy.rb', line 60

def on(table)
  rows = table.column(@column_name).uniq.inject([]) do |rows, group|
    rows << @attributes.row { |attr|
      gr = table.grouped_rows({@column_name => group}, attr.column_name)
      attr.evaluate(gr)
    }.merge(@column_name => group)
  end
  Ruport::Data::RoseTable.new(:column_names => [@column_name] | @attributes.column_names).tap do |table|
    rows.each { |row| table << row }
  end
end