Class: Symphonia::ModelFilters::BooleanFilter

Inherits:
Base
  • Object
show all
Defined in:
lib/symphonia/model_filters/boolean_filter.rb

Instance Attribute Summary

Attributes inherited from Base

#name, #operator, #options, #query, #type, #value

Instance Method Summary collapse

Methods inherited from Base

#active?, #caption, #initialize, #inspect

Constructor Details

This class inherits a constructor from Symphonia::ModelFilters::Base

Instance Method Details

#apply(scope) ⇒ Object



13
14
15
16
17
# File 'lib/symphonia/model_filters/boolean_filter.rb', line 13

def apply(scope)
  super
  t = scope.arel_table
  scope.where(t[name].send(operator, true))
end

#form_field(context) ⇒ Object



19
20
21
# File 'lib/symphonia/model_filters/boolean_filter.rb', line 19

def form_field(context)
  context.text_field_tag(form_field_name, @query.active_filters[name], class: 'form-control')
end

#operator=(to) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/symphonia/model_filters/boolean_filter.rb', line 5

def operator=(to)
  @operator = if to == '!'
                'not_eq'
              else
                'eq'
              end
end