Class: Datagrid::Filters::ExtendedBooleanFilter

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

Overview

:nodoc:

Constant Summary collapse

YES =
"YES"
NO =
"NO"

Instance Attribute Summary

Attributes inherited from BaseFilter

#block, #grid_class, #name, #options

Instance Method Summary collapse

Methods inherited from EnumFilter

#checkboxes?, #strict

Methods included from SelectOptions

#include_blank, #prompt, #select

Methods inherited from BaseFilter

#allow_blank?, #allow_nil?, #apply, #default, #default_filter_block, #dummy?, #enabled?, form_builder_helper_name, #form_builder_helper_name, #format, #header, #multiple?, #parse_values, #separator, #supports_range?, #type, #unapplicable_value?

Constructor Details

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

Returns a new instance of ExtendedBooleanFilter.


6
7
8
9
# File 'lib/datagrid/filters/extended_boolean_filter.rb', line 6

def initialize(report, attribute, options = {}, &block)
  options[:select] = -> { boolean_select }
  super(report, attribute, options, &block)
end

Instance Method Details

#execute(value, scope, grid_object) ⇒ Object


11
12
13
14
# File 'lib/datagrid/filters/extended_boolean_filter.rb', line 11

def execute(value, scope, grid_object)
  value = value.blank? ? nil : ::Datagrid::Utils.booleanize(value)
  super(value, scope, grid_object)
end

#parse(value) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/datagrid/filters/extended_boolean_filter.rb', line 16

def parse(value)
  case
  when value == true
    YES
  when value == false
    NO
  when value.blank?
    nil
  else
    super(value)
  end
end