Class: ActiveRecord::AttributeAssignment::MultiparameterAttribute

Inherits:
Object
  • Object
show all
Defined in:
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.



111
112
113
114
115
# File 'lib/active_record/attribute_assignment.rb', line 111

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

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



109
110
111
# File 'lib/active_record/attribute_assignment.rb', line 109

def column
  @column
end

#nameObject (readonly)

Returns the value of attribute name.



109
110
111
# File 'lib/active_record/attribute_assignment.rb', line 109

def name
  @name
end

#objectObject (readonly)

Returns the value of attribute object.



109
110
111
# File 'lib/active_record/attribute_assignment.rb', line 109

def object
  @object
end

#valuesObject (readonly)

Returns the value of attribute values.



109
110
111
# File 'lib/active_record/attribute_assignment.rb', line 109

def values
  @values
end

Instance Method Details

#read_valueObject



117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/active_record/attribute_assignment.rb', line 117

def read_value
  return if values.values.compact.empty?

  @column = object.class.reflect_on_aggregation(name.to_sym) || object.column_for_attribute(name)
  klass   = column.klass

  if klass == Time
    read_time
  elsif klass == Date
    read_date
  else
    read_other(klass)
  end
end