module Commons::Concerns::Extensions::SoftDeleted
Public Class Methods
default_scope()
click to toggle source
# File lib/commons/concerns/extensions/soft_deleted.rb, line 15 def self.default_scope raise ActiveModel::MissingAttributeError unless has_attribute?(:deleted_at) where(deleted_at: nil) end
Public Instance Methods
deleted?()
click to toggle source
# File lib/commons/concerns/extensions/soft_deleted.rb, line 10 def deleted? raise ActiveModel::MissingAttributeError unless has_required_fields? self.deleted_at.present? end
Private Instance Methods
check_not_deleted()
click to toggle source
# File lib/commons/concerns/extensions/soft_deleted.rb, line 23 def check_not_deleted raise ActiveModel::MissingAttributeError unless has_required_fields? raise ActiveRecord::RecordInvalid if self.deleted_at_in_database.present? end
has_required_fields?()
click to toggle source
# File lib/commons/concerns/extensions/soft_deleted.rb, line 28 def has_required_fields? self.has_attribute?(:deleted_at) end