class ActiveModel::Type::Boolean
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_model/type/boolean.rbs class ActiveModel::Type::Boolean < ActiveModel::Type::Value def cast_value: (bool value) -> bool end
-
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)
Experimental RBS support (using type sampling data from the type_fusion
project).
def cast_value: (bool value) -> bool
This signature was generated using 3 samples from 1 application.
def cast_value(value) if value == "" nil else !FALSE_VALUES.include?(value) end end
def serialize(value) # :nodoc:
def serialize(value) # :nodoc: cast(value) end
def type # :nodoc:
def type # :nodoc: :boolean end