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



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/dynamoid/persistence.rb', line 141

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