Class: ActiveRecord::AttributeAssignment::MultiparameterAttribute

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/attribute_assignment.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, name, values) ⇒ MultiparameterAttribute

Returns a new instance of MultiparameterAttribute.


120
121
122
123
124
# File 'activerecord/lib/active_record/attribute_assignment.rb', line 120

def initialize(object, name, values)
  @object = object
  @name   = name
  @values = values
end

Instance Attribute Details

#cast_typeObject (readonly)

Returns the value of attribute cast_type


118
119
120
# File 'activerecord/lib/active_record/attribute_assignment.rb', line 118

def cast_type
  @cast_type
end

#nameObject (readonly)

Returns the value of attribute name


118
119
120
# File 'activerecord/lib/active_record/attribute_assignment.rb', line 118

def name
  @name
end

#objectObject (readonly)

Returns the value of attribute object


118
119
120
# File 'activerecord/lib/active_record/attribute_assignment.rb', line 118

def object
  @object
end

#valuesObject (readonly)

Returns the value of attribute values


118
119
120
# File 'activerecord/lib/active_record/attribute_assignment.rb', line 118

def values
  @values
end

Instance Method Details

#read_valueObject


126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'activerecord/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