Class: ActiveFilter::BooleanFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/active_filter/filter/boolean_filter.rb

Instance Attribute Summary

Attributes inherited from Filter

#name

Instance Method Summary collapse

Methods inherited from Filter

#filter, #initialize, #lookup_type

Constructor Details

This class inherits a constructor from ActiveFilter::Filter

Instance Method Details

#convert_value(value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/active_filter/filter/boolean_filter.rb', line 6

def convert_value(value)
  compare_value = value.is_a?(String) ? value.downcase : value
  case compare_value
  when "no", "false", false, "0", 0
    false
  when "yes", "true", true, "1", 1
    true
  when nil
    false
  else
    !!compare_value
  end
end