Class: ActiveModel::Type::Boolean
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/boolean.rb
Overview
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
Constant Summary collapse
- FALSE_VALUES =
[ false, 0, "0", :"0", "f", :f, "F", :F, "false", :false, "FALSE", :FALSE, "off", :off, "OFF", :OFF, ].to_set.freeze
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary collapse
-
#serialize(value) ⇒ Object
:nodoc:.
-
#type ⇒ Object
:nodoc:.
Methods inherited from Value
#==, #assert_valid_value, #binary?, #cast, #changed?, #changed_in_place?, #deserialize, #force_equality?, #hash, #initialize, #map, #serializable?, #type_cast_for_schema, #value_constructed_by_mass_assignment?
Constructor Details
This class inherits a constructor from ActiveModel::Type::Value
Instance Method Details
#serialize(value) ⇒ Object
:nodoc:
32 33 34 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/boolean.rb', line 32 def serialize(value) # :nodoc: cast(value) end |
#type ⇒ Object
:nodoc:
28 29 30 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/boolean.rb', line 28 def type # :nodoc: :boolean end |