# File lib/acts_as_paranoid/core.rb, line 151 def deleted? !paranoid_value.nil? end
# File lib/acts_as_paranoid/core.rb, line 85 def destroy if paranoid_value.nil? with_transaction_returning_status do run_callbacks :destroy do self.class.delete_all(self.class.primary_key.to_sym => self.id) self.paranoid_value = self.class.delete_now_value self end end else destroy! end end
# File lib/acts_as_paranoid/core.rb, line 74 def destroy! with_transaction_returning_status do run_callbacks :destroy do destroy_dependent_associations! self.class.delete_all!(self.class.primary_key.to_sym => self.id) self.paranoid_value = self.class.delete_now_value freeze end end end
# File lib/acts_as_paranoid/core.rb, line 136 def destroy_dependent_associations! self.class.dependent_associations.each do |reflection| next unless reflection.klass.paranoid? scope = reflection.klass.only_deleted # Merge in the association's scope scope = scope.merge(association(reflection.name).association_scope) scope.each do |object| object.destroy! end end end
# File lib/acts_as_paranoid/core.rb, line 70 def paranoid_value self.send(self.class.paranoid_column) end
# File lib/acts_as_paranoid/core.rb, line 99 def recover(options={}) options = { :recursive => self.class.paranoid_configuration[:recover_dependent_associations], :recovery_window => self.class.paranoid_configuration[:dependent_recovery_window] }.merge(options) self.class.transaction do run_callbacks :recover do recover_dependent_associations(options[:recovery_window], options) if options[:recursive] self.paranoid_value = nil self.save end end end
# File lib/acts_as_paranoid/core.rb, line 115 def recover_dependent_associations(window, options) self.class.dependent_associations.each do |reflection| next unless reflection.klass.paranoid? scope = reflection.klass.only_deleted # Merge in the association's scope scope = scope.merge(association(reflection.name).association_scope) # We can only recover by window if both parent and dependant have a # paranoid column type of :time. if self.class.paranoid_column_type == :time && reflection.klass.paranoid_column_type == :time scope = scope.merge(reflection.klass.deleted_inside_time_window(paranoid_value, window)) end scope.each do |object| object.recover(options) end end end
Generated with the Darkfish Rdoc Generator 2.