Module: ActsAsParanoid
- Defined in:
- lib/acts_as_paranoid.rb,
lib/acts_as_paranoid/core.rb,
lib/acts_as_paranoid/version.rb,
lib/acts_as_paranoid/relation.rb,
lib/acts_as_paranoid/validations.rb,
lib/acts_as_paranoid/associations.rb,
lib/acts_as_paranoid/association_reflection.rb
Defined Under Namespace
Modules: AssociationReflection, Associations, Core, Relation, Validations
Constant Summary
collapse
- VERSION =
"0.10.2"
Instance Method Summary
collapse
Instance Method Details
#acts_as_paranoid(options = {}) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/acts_as_paranoid.rb', line 19
def acts_as_paranoid(options = {})
if !options.is_a?(Hash) && !options.empty?
raise ArgumentError, "Hash expected, got #{options.class.name}"
end
class_attribute :paranoid_configuration
self.paranoid_configuration = {
column: "deleted_at",
column_type: "time",
recover_dependent_associations: true,
dependent_recovery_window: 2.minutes,
double_tap_destroys_fully: true
}
paranoid_configuration[:deleted_value] = "deleted" if options[:column_type] == "string"
paranoid_configuration.merge!(options)
unless %w[time boolean string].include? paranoid_configuration[:column_type]
raise ArgumentError,
"'time', 'boolean' or 'string' expected for :column_type option," \
" got #{paranoid_configuration[:column_type]}"
end
return if paranoid?
include ActsAsParanoid::Core
default_scope { where(paranoid_default_scope) }
define_deleted_time_scopes if paranoid_column_type == :time
end
|
#paranoid? ⇒ Boolean
11
12
13
|
# File 'lib/acts_as_paranoid.rb', line 11
def paranoid?
included_modules.include?(ActsAsParanoid::Core)
end
|
#validates_as_paranoid ⇒ Object