Class: ActiveModel::Type::Boolean
- Defined in:
 - lib/active_model/type/boolean.rb
 
Overview
Active Model Boolean Type
A class that behaves like a boolean type, including rules for coercion of user input.
- 
"false","f","0",0or any other value inFALSE_VALUESwill 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:.
 - 
  
    
      #serialize_cast_value(value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 
Methods inherited from Value
#==, #as_json, #assert_valid_value, #binary?, #cast, #changed?, #changed_in_place?, #deserialize, #force_equality?, #hash, #initialize, #map, #mutable?, #serializable?, #serialized?, #type_cast_for_schema, #value_constructed_by_mass_assignment?
Methods included from SerializeCastValue
included, #initialize, #itself_if_serialize_cast_value_compatible, serialize
Constructor Details
This class inherits a constructor from ActiveModel::Type::Value
Instance Method Details
#serialize(value) ⇒ Object
:nodoc:
      30 31 32  | 
    
      # File 'lib/active_model/type/boolean.rb', line 30 def serialize(value) # :nodoc: cast(value) end  | 
  
#serialize_cast_value(value) ⇒ Object
:nodoc:
      34 35 36  | 
    
      # File 'lib/active_model/type/boolean.rb', line 34 def serialize_cast_value(value) # :nodoc: value end  | 
  
#type ⇒ Object
:nodoc:
      26 27 28  | 
    
      # File 'lib/active_model/type/boolean.rb', line 26 def type # :nodoc: :boolean end  |