rails3_acts_as_paranoid 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/acts_as_paranoid/core.rb +10 -5
  2. metadata +5 -5
@@ -134,11 +134,16 @@ module ActsAsParanoid
134
134
  end
135
135
 
136
136
  def destroy_dependent_associations!
137
- self.class.dependent_associations.each do |association|
138
- if association.collection? && self.send(association.name).paranoid?
139
- association.klass.with_deleted.instance_eval("find_all_by_#{association.foreign_key}(#{self.id.to_json})").each do |object|
140
- object.destroy!
141
- end
137
+ self.class.dependent_associations.each do |reflection|
138
+ next unless reflection.klass.paranoid?
139
+
140
+ scope = reflection.klass.only_deleted
141
+
142
+ # Merge in the association's scope
143
+ scope = scope.merge(association(reflection.name).association_scope)
144
+
145
+ scope.each do |object|
146
+ object.destroy!
142
147
  end
143
148
  end
144
149
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails3_acts_as_paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-11 00:00:00.000000000 Z
12
+ date: 2012-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70201325143880 !ruby/object:Gem::Requirement
16
+ requirement: &70127635131740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70201325143880
24
+ version_requirements: *70127635131740
25
25
  description: Active Record (~>3.2) plugin which allows you to hide and restore records
26
26
  without actually deleting them. Check its GitHub page for more in-depth information.
27
27
  email:
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
51
  version: '0'
52
52
  segments:
53
53
  - 0
54
- hash: -2548769094078379763
54
+ hash: -64246137281541820
55
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements: