Class: ActiveMetric::ReportViewModel

Inherits:
Object
  • Object
show all
Defined in:
lib/active_metric/report_view_model.rb

Defined Under Namespace

Classes: CellViewModel, ColumnTemplate, RowViewModel, TableDoesNotExist, TableTemplate, TableViewModel

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReportViewModel

Returns a new instance of ReportViewModel.



7
8
9
# File 'lib/active_metric/report_view_model.rb', line 7

def initialize
  @tables = []
end

Instance Attribute Details

#tablesObject (readonly)

Returns the value of attribute tables.



3
4
5
# File 'lib/active_metric/report_view_model.rb', line 3

def tables
  @tables
end

Class Method Details

.column(header, field, format_options = {}) ⇒ Object



20
21
22
# File 'lib/active_metric/report_view_model.rb', line 20

def self.column(header, field, format_options = {})
  @current_template.add_column(header,field,format_options)
end

.table(table_name) ⇒ Object



11
12
13
14
# File 'lib/active_metric/report_view_model.rb', line 11

def self.table(table_name)
  table_templates[table_name] =  @current_template = TableTemplate.new(table_name)
  yield
end

.table_templatesObject



16
17
18
# File 'lib/active_metric/report_view_model.rb', line 16

def self.table_templates
  @table_templates ||= {}
end

Instance Method Details

#add_table(table_name, table_data, options = {}) ⇒ Object

Raises:



24
25
26
27
28
# File 'lib/active_metric/report_view_model.rb', line 24

def add_table(table_name, table_data, options = {})
  template = self.class.table_templates[table_name]
  raise TableDoesNotExist unless template
  tables << TableViewModel.new(template, table_data, options)
end