Module: Immortal::ClassMethods
- Defined in:
- lib/immortal.rb
Instance Method Summary collapse
- #count_only_deleted(*args) ⇒ Object
- #count_with_deleted(*args) ⇒ Object
- #delete_all!(*args) ⇒ Object
- #deleted_clause_sql ⇒ Object
- #find_only_deleted(*args) ⇒ Object
- #find_with_deleted(*args) ⇒ Object
- #immortal? ⇒ Boolean
- #immortal_delete_all(conditions = nil) ⇒ Object
- #only_deleted ⇒ Object
- #undeleted_clause_sql ⇒ Object
- #with_deleted ⇒ Object
Instance Method Details
#count_only_deleted(*args) ⇒ Object
54 55 56 |
# File 'lib/immortal.rb', line 54 def count_only_deleted(*args) only_deleted.count(*args) end |
#count_with_deleted(*args) ⇒ Object
50 51 52 |
# File 'lib/immortal.rb', line 50 def count_with_deleted(*args) with_deleted.count(*args) end |
#delete_all!(*args) ⇒ Object
70 71 72 |
# File 'lib/immortal.rb', line 70 def delete_all!(*args) unscoped.mortal_delete_all(*args) end |
#deleted_clause_sql ⇒ Object
78 79 80 |
# File 'lib/immortal.rb', line 78 def deleted_clause_sql unscoped.where(arel_table[:deleted].eq(true)).where_clauses.first end |
#find_only_deleted(*args) ⇒ Object
62 63 64 |
# File 'lib/immortal.rb', line 62 def find_only_deleted(*args) only_deleted.find(*args) end |
#find_with_deleted(*args) ⇒ Object
58 59 60 |
# File 'lib/immortal.rb', line 58 def find_with_deleted(*args) with_deleted.find(*args) end |
#immortal? ⇒ Boolean
34 35 36 |
# File 'lib/immortal.rb', line 34 def immortal? self.included_modules.include?(::Immortal::InstanceMethods) end |
#immortal_delete_all(conditions = nil) ⇒ Object
66 67 68 |
# File 'lib/immortal.rb', line 66 def immortal_delete_all(conditions = nil) unscoped.update_all({:deleted => 1}, conditions) end |
#only_deleted ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/immortal.rb', line 42 def only_deleted deleted_clause = arel_table[:deleted].eq(true) where_sql_clauses = filter_undeleted_where_clauses where_sql_clauses.concat unscoped.where(deleted_clause).where_clauses except(:where).where(where_sql_clauses.join(" AND ")) end |
#undeleted_clause_sql ⇒ Object
74 75 76 |
# File 'lib/immortal.rb', line 74 def undeleted_clause_sql unscoped.where(arel_table[:deleted].eq(nil).or(arel_table[:deleted].eq(false))).where_clauses.first end |
#with_deleted ⇒ Object
38 39 40 |
# File 'lib/immortal.rb', line 38 def with_deleted except(:where).where(filter_undeleted_where_clauses.join(' AND ')) end |