Class: ParamsReady::Value::BooleanCoder
- Inherits:
-
Coder
- Object
- Coder
- ParamsReady::Value::BooleanCoder
show all
- Defined in:
- lib/params_ready/value/coder.rb
Class Method Summary
collapse
Methods inherited from Coder
value_class_name
#class_reader_writer
Methods included from Coercion
#strict_default?, #try_coerce
Class Method Details
.coerce(input, _) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/params_ready/value/coder.rb', line 101
def self.coerce(input, _)
return nil if input.nil? || input == ''
return input if input.is_a?(TrueClass) || input.is_a?(FalseClass)
str = input.to_s
case str
when 'true', 'TRUE', 't', 'T', '1'
true
when 'false', 'FALSE', 'f', 'F', '0'
false
else
raise
end
end
|
115
116
117
|
# File 'lib/params_ready/value/coder.rb', line 115
def self.format(value, format)
value.to_s
end
|