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