class ParamsReady::Value::BooleanCoder

Public Class Methods

coerce(input, _) click to toggle source
# File lib/params_ready/value/coder.rb, line 124
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
format(value, format) click to toggle source
# File lib/params_ready/value/coder.rb, line 138
def self.format(value, format)
  value.to_s
end