Method: SimpleRecord::ActiveSdb::Base#put

Defined in:
lib/simple_record/active_sdb.rb

#putObject

Stores in-memory attributes to SDB. Adds the attributes values to already stored at SDB. Returns a hash of stored attributes.

sandy = Client.new(:name => 'Sandy') #=> #<Client:0xb775a7a8 @attributes={"name"=>["Sandy"]}, @new_record=true>
sandy['toys'] = 'boys'
sandy.put
sandy['toys'] = 'patchwork'
sandy.put
sandy['toys'] = 'kids'
sandy.put
puts sandy.attributes.inspect        #=> {"name"=>["Sandy"], "id"=>"b2832ce2-e461-11dc-b13c-001bfc466dd7", "toys"=>["kids"]}
sandy.reload                         #=> {"name"=>["Sandy"], "id"=>"b2832ce2-e461-11dc-b13c-001bfc466dd7", "toys"=>["boys", "kids", "patchwork"]}

compare to save method



806
807
808
809
810
811
812
813
814
815
# File 'lib/simple_record/active_sdb.rb', line 806

def put
    @attributes = uniq_values(@attributes)
    prepare_for_update
    attrs       = @attributes.dup
    attrs.delete('id')
    connection.put_attributes(domain, id, attrs) unless attrs.blank?
    connection.put_attributes(domain, id, {'id' => id}, :replace)
    mark_as_old
    @attributes
end