Class: AttributeExtensions::Typecasting::BooleanTypecaster
- Inherits:
-
Object
- Object
- AttributeExtensions::Typecasting::BooleanTypecaster
- Defined in:
- lib/attribute_extensions/typecasting/boolean_typecaster.rb
Constant Summary collapse
- TRUE_VALUES =
[true, 1, "1", "t", "T", "true", "TRUE", "on", "ON"]
Instance Method Summary collapse
Instance Method Details
#call(value) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/attribute_extensions/typecasting/boolean_typecaster.rb', line 6 def call(value) if value.is_a?(String) && value !~ /[^[:space:]]/ nil else TRUE_VALUES.include?(value) end end |