Module: Ardm::Property::ParanoidBase

Extended by:
ActiveSupport::Concern
Defined in:
lib/ardm/property/support/paranoid_base.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#destroy(execute_hooks = true) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ardm/property/support/paranoid_base.rb', line 23

def destroy(execute_hooks = true)
  # NOTE: changed behavior because AR doesn't call hooks on destroying new objects
  return false if new_record?
  if execute_hooks
    run_callbacks :destroy do
      paranoid_destroy
    end
  else
    super
  end
end

#paranoid_destroyObject



14
15
16
17
18
19
20
21
# File 'lib/ardm/property/support/paranoid_base.rb', line 14

def paranoid_destroy
  self.class.paranoid_properties.each do |name, block|
    attribute_set(name, block.call(self))
  end
  save
  @readonly = true
  true
end