is_paranoid_ext 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{is_paranoid_ext}
3
- s.version = "0.0.5"
3
+ s.version = "0.0.6"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Alex Neill"]
7
- s.date = %q{2010-05-06}
7
+ s.date = %q{2010-06-08}
8
8
  s.description = %q{}
9
9
  s.email = %q{alex@featureless.co.uk}
10
10
  s.extra_rdoc_files = [
@@ -2,31 +2,40 @@ require 'activerecord'
2
2
 
3
3
  module IsParanoidExt
4
4
 
5
- def preload_has_one_association(records, reflection, preload_options = {})
6
- super(records, reflection, paranoid_preload_options(reflection, preload_options))
7
- end
8
-
9
- def preload_has_many_association(records, reflection, preload_options = {})
10
- super(records, reflection, paranoid_preload_options(reflection, preload_options))
11
- end
12
-
13
- def preload_has_and_belongs_to_many_association(records, reflection, preload_options = {})
14
- super(records, reflection, paranoid_preload_options(reflection, preload_options))
15
- end
16
-
17
5
  private
18
6
 
19
- def paranoid_preload_options(reflection, preload_options)
20
- paranoid_preload_opts = preload_options.dup
21
- if reflection.klass.respond_to?(:restore)
22
- sql_array = ["#{reflection.klass.quoted_table_name}.#{reflection.klass.destroyed_field} IS ?"]
23
- sql_array << reflection.klass.field_not_destroyed
24
- preload_conditions = paranoid_preload_opts.delete(:conditions) || []
25
- paranoid_preload_opts.merge(:conditions => merge_conditions(sql_array, preload_conditions))
7
+ def construct_finder_sql_with_included_associations(options, join_dependency)
8
+ preload_options = options.dup
9
+ join_dependency.reflections.each do |reflection|
10
+ preload_options = paranoid_preload_options(reflection, preload_options)
11
+ end
12
+ super(preload_options, join_dependency)
13
+ end
14
+
15
+ def preload_has_one_association(records, reflection, preload_options = {})
16
+ super(records, reflection, paranoid_preload_options(reflection, preload_options))
17
+ end
18
+
19
+ def preload_has_many_association(records, reflection, preload_options = {})
20
+ super(records, reflection, paranoid_preload_options(reflection, preload_options))
21
+ end
22
+
23
+ def preload_has_and_belongs_to_many_association(records, reflection, preload_options = {})
24
+ super(records, reflection, paranoid_preload_options(reflection, preload_options))
25
+ end
26
+
27
+ def paranoid_preload_options(reflection, preload_options)
28
+ paranoid_preload_opts = preload_options.dup
29
+ if reflection.klass.respond_to?(:restore)
30
+ sql_array = ["#{reflection.klass.quoted_table_name}.#{reflection.klass.destroyed_field} IS ?"]
31
+ sql_array << reflection.klass.field_not_destroyed
32
+ preload_conditions = paranoid_preload_opts.delete(:conditions) || []
33
+ paranoid_preload_opts.merge!(:conditions => merge_conditions(sql_array, preload_conditions))
34
+ end
35
+ paranoid_preload_opts
26
36
  end
27
- paranoid_preload_opts
28
- end
29
37
 
30
38
  end
31
39
 
32
40
  ActiveRecord::Base.send(:extend, IsParanoidExt)
41
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alex Neill
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-06 00:00:00 +01:00
17
+ date: 2010-06-08 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20