Class: ActiveRemote::Typecasting::BooleanTypecaster
- Inherits:
-
Object
- Object
- ActiveRemote::Typecasting::BooleanTypecaster
- Defined in:
- lib/active_remote/typecasting/boolean_typecaster.rb
Constant Summary collapse
- BOOL_VALUES =
[true, false].freeze
- FALSE_VALUES =
["n", "N", "no", "No", "NO", "false", "False", "FALSE", "off", "Off", "OFF", "f", "F"]
Class Method Summary collapse
Class Method Details
.call(value) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/active_remote/typecasting/boolean_typecaster.rb', line 7 def self.call(value) return value if BOOL_VALUES.include?(value) case value when *FALSE_VALUES then false when Numeric, /^\-?[0-9]/ then !value.to_f.zero? else value.present? end end |