Module: GuardAgainstPhysicalDelete::Base::ClassMethods

Defined in:
lib/guard_against_physical_delete/base.rb

Instance Method Summary collapse

Instance Method Details

#delete_permitted?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
# File 'lib/guard_against_physical_delete/base.rb', line 30

def delete_permitted?
  return true unless physical_delete_permission[self.name].zero?
  return false if logical_delete?
  return true
end

#logical_delete?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/guard_against_physical_delete/base.rb', line 26

def logical_delete?
  self.column_names.include? logical_delete_column.to_s
end

#physical_deleteObject



19
20
21
22
23
24
# File 'lib/guard_against_physical_delete/base.rb', line 19

def physical_delete
  physical_delete_permission[self.name] += 1
  yield
ensure
  physical_delete_permission[self.name] -= 1
end