class ActiveModel::Type::Boolean
-
All other values will be coerced to
true
- Empty strings are coerced tonil
- “false”, “f” , “0”,0
or any other value inFALSE_VALUES
will be coerced tofalse
Coercion behavior is roughly mapped to Ruby’s boolean semantics.
Values set from user input will first be coerced into the appropriate ruby type.
=== Coercion
A class that behaves like a boolean type, including rules for coercion of user input.
== Active Model Type Boolean
def cast_value(value)
def cast_value(value) if value == "" nil else !FALSE_VALUES.include?(value) end end
def type # :nodoc:
def type # :nodoc: :boolean end