Method: Dynamoid::Persistence#delete
- Defined in:
- lib/dynamoid/persistence.rb
#delete ⇒ Object
Delete this object from the datastore.
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/dynamoid/persistence.rb', line 266 def delete = range_key ? { range_key: Dumping.dump_field(read_attribute(range_key), self.class.attributes[range_key]) } : {} # Add an optimistic locking check if the lock_version column exists if self.class.attributes[:lock_version] conditions = { if: {} } conditions[:if][:lock_version] = if changes[:lock_version].nil? lock_version else changes[:lock_version][0] end [:conditions] = conditions end Dynamoid.adapter.delete(self.class.table_name, hash_key, ) rescue Dynamoid::Errors::ConditionalCheckFailedException raise Dynamoid::Errors::StaleObjectError.new(self, 'delete') end |