Method: Dynamoid::Fields#write_attribute

Defined in:
lib/dynamoid/fields.rb

#write_attribute(name, value) ⇒ Object Also known as: []=

Write an attribute on the object. Also marks the previous value as dirty.

Parameters:

  • name (Symbol)

    the name of the field

  • value (Object)

    the value to assign to that field

Since:

  • 0.2.0



117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/dynamoid/fields.rb', line 117

def write_attribute(name, value)
  name = name.to_sym

  if association = @associations[name]
    association.reset
  end

  @attributes_before_type_cast[name] = value

  value_casted = TypeCasting.cast_field(value, self.class.attributes[name])
  attributes[name] = value_casted
end