Class: QueryReport::Report

Inherits:
Object
  • Object
show all
Includes:
ColumnChartModule, ColumnModule, FilterModule, PaginateModule, PieChartModule, Record
Defined in:
lib/query_report/report.rb

Instance Attribute Summary collapse

Attributes included from Record

#query

Attributes included from FilterModule

#filters, #search

Attributes included from ColumnModule

#columns

Instance Method Summary collapse

Methods included from PieChartModule

#pie_chart

Methods included from ColumnChartModule

#column_chart

Methods included from Record

#all_records, #apply, #filtered_query, #map_record, #model_class, #paginated_query, #records, #search

Methods included from PaginateModule

#apply_pagination

Methods included from FilterModule

#apply_filters, #filter, #load_default_values_in_param

Methods included from ColumnModule

#column

Constructor Details

#initialize(params, template, options = {}, &block) ⇒ Report

Returns a new instance of Report.



21
22
23
24
25
26
# File 'lib/query_report/report.rb', line 21

def initialize(params, template, options={}, &block)
  @params, @template = params, template
  @columns, @filters, @charts = [], [], []
  @options = QueryReport::DEFAULT_OPTIONS.merge options
  instance_eval &block if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object

to support the helper methods



42
43
44
45
46
47
48
# File 'lib/query_report/report.rb', line 42

def method_missing(meth, *args, &block)
  if @template.respond_to?(meth)
    @template.send(meth, *args)
  else
    super
  end
end

Instance Attribute Details

#chartsObject (readonly)

Returns the value of attribute charts.



19
20
21
# File 'lib/query_report/report.rb', line 19

def charts
  @charts
end

#optionsObject (readonly)

Returns the value of attribute options.



19
20
21
# File 'lib/query_report/report.rb', line 19

def options
  @options
end

#paramsObject (readonly)

Returns the value of attribute params.



19
20
21
# File 'lib/query_report/report.rb', line 19

def params
  @params
end

#templateObject (readonly)

Returns the value of attribute template.



19
20
21
# File 'lib/query_report/report.rb', line 19

def template
  @template
end

Instance Method Details

#has_chart?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/query_report/report.rb', line 37

def has_chart?
  !@charts.empty?
end