Module: AttributeNormalizer::Normalizers::BooleanNormalizer

Defined in:
lib/attribute_normalizer/normalizers/boolean_normalizer.rb

Constant Summary collapse

TRUE_VALUES =
[true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON'].to_set

Class Method Summary collapse

Class Method Details

.normalize(value, options = {}) ⇒ Object


9
10
11
12
13
14
15
# File 'lib/attribute_normalizer/normalizers/boolean_normalizer.rb', line 9

def self.normalize(value, options = {})
  if value.is_a?(String) && value.blank?
    nil
  else
    TRUE_VALUES.include?(value)
  end
end