Method: ActiveData::Model::Lifecycle#destroy

Defined in:
lib/active_data/model/lifecycle.rb

#destroy(&block) ⇒ Object

Destroys object by calling the destroy performer. Returns instance in any case. Changes persisted? to false and destroyed? to true in case of success.

author.destroy

If destroy performer is not defined with define_destroy, it raises ActiveData::UndestroyableObject. Also destroy performer block might be passed instead of in-class performer definition:

author.destroy { REDIS.del(id) }


236
237
238
239
240
# File 'lib/active_data/model/lifecycle.rb', line 236

def destroy(&block)
  raise ActiveData::UndestroyableObject unless block || destroyable?
  destroy_object(&block)
  self
end