Module: MongoMapper::Plugins::Paranoia::InstanceMethods

Defined in:
lib/mongo_mapper/paranoia.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject Also known as: delete

Destroys the instance

See Also:

  • update_attribute


22
23
24
25
26
# File 'lib/mongo_mapper/paranoia.rb', line 22

def destroy
  run_callbacks(:destroy) do
    update_attribute(:deleted_at, Time.now)
  end
end

#destroyed?true, false Also known as: deleted?

Returns Whether or not the deleted_at attribute is set.

Returns:

  • (true, false)

    Whether or not the deleted_at attribute is set



30
31
32
# File 'lib/mongo_mapper/paranoia.rb', line 30

def destroyed?
  self.deleted_at.present?
end

#ensure_activeObject Also known as: undestroy, undelete

Sets the deleted_at attribute to nil, if present

See Also:

  • update_attribute


37
38
39
40
41
# File 'lib/mongo_mapper/paranoia.rb', line 37

def ensure_active
  run_callbacks(:destroy) do
    update_attribute(:deleted_at, nil)
  end
end