Class: ActiveRecord::AttributeAssignment::MultiparameterAttribute
- Inherits:
-
Object
- Object
- ActiveRecord::AttributeAssignment::MultiparameterAttribute
- Defined in:
- lib/active_record/attribute_assignment.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#cast_type ⇒ Object
readonly
Returns the value of attribute cast_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(object, name, values) ⇒ MultiparameterAttribute
constructor
A new instance of MultiparameterAttribute.
- #read_value ⇒ Object
Constructor Details
#initialize(object, name, values) ⇒ MultiparameterAttribute
Returns a new instance of MultiparameterAttribute.
120 121 122 123 124 |
# File 'lib/active_record/attribute_assignment.rb', line 120 def initialize(object, name, values) @object = object @name = name @values = values end |
Instance Attribute Details
#cast_type ⇒ Object (readonly)
Returns the value of attribute cast_type.
118 119 120 |
# File 'lib/active_record/attribute_assignment.rb', line 118 def cast_type @cast_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
118 119 120 |
# File 'lib/active_record/attribute_assignment.rb', line 118 def name @name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
118 119 120 |
# File 'lib/active_record/attribute_assignment.rb', line 118 def object @object end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
118 119 120 |
# File 'lib/active_record/attribute_assignment.rb', line 118 def values @values end |
Instance Method Details
#read_value ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/active_record/attribute_assignment.rb', line 126 def read_value return if values.values.compact.empty? @cast_type = object.type_for_attribute(name) klass = cast_type.klass if klass == Time read_time elsif klass == Date read_date else read_other end end |