Module: Cms::Behaviors::SoftDeleting::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#count(*args) ⇒ Object



30
31
32
# File 'lib/cms/behaviors/soft_deleting.rb', line 30

def count(*args)
  not_deleted.count_with_deleted(*args)
end

#delete_all(conditions = nil) ⇒ Object



33
34
35
# File 'lib/cms/behaviors/soft_deleting.rb', line 33

def delete_all(conditions=nil)
  update_all(["deleted = ?", true], conditions)
end

#exists?(id_or_conditions) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
# File 'lib/cms/behaviors/soft_deleting.rb', line 36

def exists?(id_or_conditions)
  if id_or_conditions.is_a?(Hash) || id_or_conditions.is_a?(Array)
    conditions = {:conditions => id_or_conditions}
  else
    conditions = {:conditions => {:id => id_or_conditions}}
  end
  count(conditions) > 0
end

#find(*args) ⇒ Object



27
28
29
# File 'lib/cms/behaviors/soft_deleting.rb', line 27

def find(*args)
  not_deleted.find_with_deleted(*args)
end