module Immortal::ClassMethods
Public Instance Methods
count_only_deleted(*args)
click to toggle source
# File lib/immortal.rb, line 44 def count_only_deleted(*args) without_default_scope do immortal.count(*args) end end
count_with_deleted(*args)
click to toggle source
# File lib/immortal.rb, line 38 def count_with_deleted(*args) without_default_scope do count(*args) end end
delete_all!(*args)
click to toggle source
# File lib/immortal.rb, line 66 def delete_all!(*args) unscoped.mortal_delete_all(*args) end
deleted_clause_sql()
click to toggle source
# File lib/immortal.rb, line 74 def deleted_clause_sql unscoped.where(arel_table[COLUMN_NAME].eq(true)).constraints.first.to_sql end
exists?(id = false)
click to toggle source
# File lib/immortal.rb, line 34 def exists?(id = false) mortal.exists?(id) end
immortal?()
click to toggle source
@return [Boolean] whether the model supports immortal or not
# File lib/immortal.rb, line 22 def immortal? included_modules.include?(::Immortal::InstanceMethods) end
immortal_delete_all(conditions = nil)
click to toggle source
# File lib/immortal.rb, line 62 def immortal_delete_all(conditions = nil) unscoped.where(conditions).update_all(COLUMN_NAME => 1) end
undeleted_clause_sql()
click to toggle source
# File lib/immortal.rb, line 70 def undeleted_clause_sql unscoped.mortal.constraints.first.to_sql end
where_only_deleted(conditions)
click to toggle source
# File lib/immortal.rb, line 56 def where_only_deleted(conditions) without_default_scope do immortal.where(conditions) end end
where_with_deleted(conditions)
click to toggle source
# File lib/immortal.rb, line 50 def where_with_deleted(conditions) without_default_scope do where(conditions) end end
without_default_scope() { || ... }
click to toggle source
# File lib/immortal.rb, line 26 def without_default_scope where_clause = (current_scope || unscoped).where_values_hash.except(COLUMN_NAME) unscoped.where(where_clause).scoping do yield end end