Module: ActsAsParanoid::ClassMethods
- Defined in:
- lib/rails3_acts_as_paranoid.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_recover(method) ⇒ Object
- #before_recover(method) ⇒ Object
- #delete_all(conditions = nil) ⇒ Object
- #delete_all!(conditions = nil) ⇒ Object
- #delete_now_value ⇒ Object
- #dependent_associations ⇒ Object
- #only_deleted ⇒ Object
- #paranoid_column ⇒ Object
- #paranoid_column_type ⇒ Object
- #with_deleted ⇒ Object
Class Method Details
.extended(base) ⇒ Object
51 52 53 |
# File 'lib/rails3_acts_as_paranoid.rb', line 51 def self.extended(base) base.define_callbacks :recover end |
Instance Method Details
#after_recover(method) ⇒ Object
59 60 61 |
# File 'lib/rails3_acts_as_paranoid.rb', line 59 def after_recover(method) set_callback :recover, :after, method end |
#before_recover(method) ⇒ Object
55 56 57 |
# File 'lib/rails3_acts_as_paranoid.rb', line 55 def before_recover(method) set_callback :recover, :before, method end |
#delete_all(conditions = nil) ⇒ Object
75 76 77 |
# File 'lib/rails3_acts_as_paranoid.rb', line 75 def delete_all(conditions = nil) update_all ["#{paranoid_configuration[:column]} = ?", delete_now_value], conditions end |
#delete_all!(conditions = nil) ⇒ Object
71 72 73 |
# File 'lib/rails3_acts_as_paranoid.rb', line 71 def delete_all!(conditions = nil) self.unscoped.delete_all!(conditions) end |
#delete_now_value ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/rails3_acts_as_paranoid.rb', line 91 def delete_now_value case paranoid_configuration[:column_type] when "time" then Time.now when "boolean" then true when "string" then paranoid_configuration[:deleted_value] end end |
#dependent_associations ⇒ Object
87 88 89 |
# File 'lib/rails3_acts_as_paranoid.rb', line 87 def dependent_associations self.reflect_on_all_associations.select {|a| [:destroy, :delete_all].include?(a.[:dependent]) } end |
#only_deleted ⇒ Object
67 68 69 |
# File 'lib/rails3_acts_as_paranoid.rb', line 67 def only_deleted self.unscoped.where("#{paranoid_column_reference} IS NOT ?", nil) end |
#paranoid_column ⇒ Object
79 80 81 |
# File 'lib/rails3_acts_as_paranoid.rb', line 79 def paranoid_column paranoid_configuration[:column].to_sym end |
#paranoid_column_type ⇒ Object
83 84 85 |
# File 'lib/rails3_acts_as_paranoid.rb', line 83 def paranoid_column_type paranoid_configuration[:column_type].to_sym end |
#with_deleted ⇒ Object
63 64 65 |
# File 'lib/rails3_acts_as_paranoid.rb', line 63 def with_deleted self.unscoped end |