Module: Cms::Behaviors::SoftDeleting::MacroMethods

Defined in:
lib/cms/behaviors/soft_deleting.rb

Instance Method Summary collapse

Instance Method Details

#uses_soft_delete(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cms/behaviors/soft_deleting.rb', line 11

def uses_soft_delete(options={})
  @uses_soft_delete = true

  named_scope :not_deleted, :conditions => ["#{table_name}.deleted = ?", false]
  class << self
    alias_method :find_with_deleted, :find
    alias_method :count_with_deleted, :count
    alias_method :delete_all!, :delete_all
  end
  alias_method :destroy_without_callbacks!, :destroy_without_callbacks

  extend ClassMethods
  include InstanceMethods
end

#uses_soft_delete?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/cms/behaviors/soft_deleting.rb', line 8

def uses_soft_delete?
  !!@uses_soft_delete
end