Class: Reporta::Form

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Conversion, ActiveModel::Validations
Defined in:
lib/reporta/models/form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filters, values = {}) ⇒ Form

Returns a new instance of Form.



38
39
40
41
42
43
44
# File 'lib/reporta/models/form.rb', line 38

def initialize(filters, values={})
  @filters = filters
  @params = values
  self.class.send :attr_accessor, *filters.keys
  self.filter_applied = values.any?
  set_values filters, values
end

Instance Attribute Details

#filter_appliedObject

Returns the value of attribute filter_applied.



27
28
29
# File 'lib/reporta/models/form.rb', line 27

def filter_applied
  @filter_applied
end

#filtersObject

Returns the value of attribute filters.



27
28
29
# File 'lib/reporta/models/form.rb', line 27

def filters
  @filters
end

#paramsObject

Returns the value of attribute params.



27
28
29
# File 'lib/reporta/models/form.rb', line 27

def params
  @params
end

Instance Method Details

#filter_applied?Boolean

Returns:

  • (Boolean)


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

def filter_applied?
  self.filter_applied
end

#persisted?Boolean

This method is required so a Form instance can be passed into a form_for helper method

Returns:

  • (Boolean)


52
53
54
# File 'lib/reporta/models/form.rb', line 52

def persisted?
  false
end