Method: Dynamoid::Persistence#save

Defined in:
lib/dynamoid/persistence.rb

#save(options = {}) ⇒ Object

Run the callbacks and then persist this object in the datastore.

Since:

  • 0.2.0



287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/dynamoid/persistence.rb', line 287

def save(options = {})
  self.class.create_table

  if new_record?
    conditions = { unless_exists: [self.class.hash_key]}
    conditions[:unless_exists] << range_key if(range_key)

    run_callbacks(:create) { persist(conditions) }
  else
    persist
  end
end