Class: ContainerConfig::Coercer::Boolean
- Defined in:
- lib/container_config/coercer/boolean.rb
Overview
Boolean type coercer
Instance Method Summary collapse
-
#coerce(value) ⇒ Boolean
Coerces the given value into a boolean.
- #name ⇒ Object
- #type ⇒ Object
Instance Method Details
#coerce(value) ⇒ Boolean
Coerces the given value into a boolean
26 27 28 29 30 31 |
# File 'lib/container_config/coercer/boolean.rb', line 26 def coerce(value) # If a digit is passed, check if it is non-zero and return true for non-zero values return value.to_i != 0 if value.respond_to?(:to_i) && value.to_i.to_s == value.to_s value.to_s.casecmp?("true") end |
#name ⇒ Object
10 11 12 |
# File 'lib/container_config/coercer/boolean.rb', line 10 def name "Boolean" end |
#type ⇒ Object
15 16 17 |
# File 'lib/container_config/coercer/boolean.rb', line 15 def type :boolean end |