Class: QueryReport::Report

Inherits:
Object
  • Object
show all
Includes:
ChartAdapterModule, ColumnModule, FilterModule, PaginateModule, 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 ChartAdapterModule

#chart

Methods included from Record

#all_records, #all_records_to_render, #apply, #array_record?, #content_from_element, #filtered_query, #has_any_rowspan?, #map_record, #map_rowspan, #model_class, #paginated_query, #records, #records_to_render, #search

Methods included from PaginateModule

#apply_pagination

Methods included from FilterModule

#apply_filters, #filter, #has_filter?, #load_default_values_in_param, #ordered_param_value_objects

Methods included from ColumnModule

#column, #column_total_with_colspan

Constructor Details

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

Returns a new instance of Report.



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

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



50
51
52
53
54
55
56
# File 'lib/query_report/report.rb', line 50

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.



11
12
13
# File 'lib/query_report/report.rb', line 11

def charts
  @charts
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/query_report/report.rb', line 11

def options
  @options
end

#paramsObject (readonly)

Returns the value of attribute params.



11
12
13
# File 'lib/query_report/report.rb', line 11

def params
  @params
end

#templateObject (readonly)

Returns the value of attribute template.



11
12
13
# File 'lib/query_report/report.rb', line 11

def template
  @template
end

Instance Method Details

#has_chart?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/query_report/report.rb', line 35

def has_chart?
  !@charts.empty?
end

#has_total?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/query_report/report.rb', line 39

def has_total?
  @columns.any?(&:has_total?)
end

#paginate?Boolean

Returns:

  • (Boolean)


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

def paginate?
  return false if array_record? #do not paginate on the array records
  return true if @options[:paginate].nil?
  @options[:paginate]
end