Class: Datagrid::Filters::BooleanEnumFilter

Inherits:
EnumFilter show all
Defined in:
lib/datagrid/filters/boolean_enum_filter.rb

Constant Summary collapse

YES =
"YES"
NO =
"NO"
VALUES =
ActiveSupport::OrderedHash.new

Instance Attribute Summary

Attributes inherited from BaseFilter

#block, #grid, #name, #options

Instance Method Summary collapse

Methods inherited from EnumFilter

#format, #include_blank, #prompt, #select, #strict

Methods inherited from BaseFilter

#allow_blank?, #allow_nil?, #default, #format, #format_values, #header, #multiple

Constructor Details

#initialize(report, attribute, options = {}, &block) ⇒ BooleanEnumFilter

Returns a new instance of BooleanEnumFilter.



9
10
11
12
# File 'lib/datagrid/filters/boolean_enum_filter.rb', line 9

def initialize(report, attribute, options = {}, &block)
  options[:select] = VALUES.keys
  super(report, attribute, options, &block)
end

Instance Method Details

#apply(scope, value) ⇒ Object



14
15
16
# File 'lib/datagrid/filters/boolean_enum_filter.rb', line 14

def apply(scope, value)
  super(scope, to_boolean(value))
end

#to_boolean(value) ⇒ Object



18
19
20
# File 'lib/datagrid/filters/boolean_enum_filter.rb', line 18

def to_boolean(value)
  VALUES[value]
end