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.



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

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

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



106
107
108
# File 'lib/active_record/attribute_assignment.rb', line 106

def column
  @column
end

#nameObject (readonly)

Returns the value of attribute name.



106
107
108
# File 'lib/active_record/attribute_assignment.rb', line 106

def name
  @name
end

#objectObject (readonly)

Returns the value of attribute object.



106
107
108
# File 'lib/active_record/attribute_assignment.rb', line 106

def object
  @object
end

#valuesObject (readonly)

Returns the value of attribute values.



106
107
108
# File 'lib/active_record/attribute_assignment.rb', line 106

def values
  @values
end

Instance Method Details

#read_valueObject



114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/active_record/attribute_assignment.rb', line 114

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