Class: ActiveFilter::BooleanField

Inherits:
Field
  • Object
show all
Defined in:
lib/active_filter/field.rb

Instance Attribute Summary

Attributes inherited from Field

#name

Instance Method Summary collapse

Methods inherited from Field

#filter, #initialize, #lookup_type

Constructor Details

This class inherits a constructor from ActiveFilter::Field

Instance Method Details

#convert_value(value) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/active_filter/field.rb', line 89

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