Module: Reporta::Reportable

Extended by:
ActiveSupport::Concern
Includes:
Column, Filter
Defined in:
lib/reporta/models/reportable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Column

#value_for

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Delegate any undefined message to the @form object. This allows you to call report.start_date to get the value of the start_date filter or assign a value using ‘report.start_date = ’2013-01-01’‘



46
47
48
# File 'lib/reporta/models/reportable.rb', line 46

def method_missing(*args, &block)
  self.form.send(*args, &block)
end

Instance Attribute Details

#formObject

Returns the value of attribute form.



28
29
30
# File 'lib/reporta/models/reportable.rb', line 28

def form
  @form
end

Instance Method Details

#idObject



36
37
38
# File 'lib/reporta/models/reportable.rb', line 36

def id
  self.class.name.underscore
end

#initialize(args = {}) ⇒ Object



30
31
32
33
34
# File 'lib/reporta/models/reportable.rb', line 30

def initialize(args={})
  args ||= {}
  @form = Reporta::Form.new filters, args
  form.valid? if args.present?
end