Class: Effective::DatatableFiltersForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/effective/datatable_filters_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datatable:) ⇒ DatatableFiltersForm

Returns a new instance of DatatableFiltersForm.



9
10
11
12
13
14
15
16
17
18
# File 'app/models/effective/datatable_filters_form.rb', line 9

def initialize(datatable:)
  # Assign the current value of scope
  assign_attributes(scope: datatable.state[:scope])

  # Create an attr_accesor for each filter and assign value
  datatable._filters.each do |name, options|
    self.class.send(:attr_accessor, name)
    assign_attributes(name => datatable.state[:filter][name])
  end
end

Instance Attribute Details

#scopeObject

Returns the value of attribute scope.



7
8
9
# File 'app/models/effective/datatable_filters_form.rb', line 7

def scope
  @scope
end