eager_record 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,7 +67,7 @@ module EagerRecord
67
67
  end
68
68
 
69
69
  def load_target_with_eager_preloading
70
- if @reflection.options[:conditions].nil? && (!@owner.new_record? || foreign_key_present)
70
+ if !buggy_options?(@reflection) && (!@owner.new_record? || foreign_key_present)
71
71
  if !loaded?
72
72
  if originating_collection = @owner.instance_variable_get(:@originating_collection)
73
73
  @owner.class.__send__(:preload_associations, originating_collection, @reflection.name)
@@ -77,6 +77,16 @@ module EagerRecord
77
77
  end
78
78
  load_target_without_eager_preloading
79
79
  end
80
+
81
+ private
82
+
83
+ BUGGY_OPTIONS = [ :conditions, :finder_sql, :order ]
84
+
85
+ def buggy_options?(reflection)
86
+ reflection.options.any? do |(key, value)|
87
+ BUGGY_OPTIONS.include?(key) && value.present?
88
+ end
89
+ end
80
90
  end
81
91
  end
82
92
  end
@@ -6,7 +6,7 @@ module EagerRecord
6
6
  #
7
7
  class Unmarshallable
8
8
  instance_methods.each do |method|
9
- undef_method(method) unless method =~ /__.+__/ || method.to_sym == :respond_to?
9
+ undef_method(method) unless method =~ /__.+__/ || method.to_sym == :respond_to? || method.to_sym == :object_id
10
10
  end
11
11
 
12
12
  class <<self
@@ -1,3 +1,3 @@
1
1
  module EagerRecord
2
- VERSION = '0.1.3'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eager_record
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mat Brown
@@ -15,13 +15,28 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-04 00:00:00 -05:00
19
- default_executable:
18
+ date: 2013-06-12 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: rspec
21
+ name: activerecord
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 2
31
+ - 3
32
+ - 0
33
+ version: 2.3.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
25
40
  none: false
26
41
  requirements:
27
42
  - - ">="
@@ -31,7 +46,21 @@ dependencies:
31
46
  - 0
32
47
  version: "0"
33
48
  type: :development
34
- version_requirements: *id001
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: sqlite3-ruby
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :development
63
+ version_requirements: *id003
35
64
  description: EagerRecord extends ActiveRecord to automate association preloading. Each time a collection of more than one record is loaded from the database, each record remembers the collection that it is part of; then when one of those records has an association accessed, EagerRecord triggers a preload_associations for all the records in the originating collection. Never worry about that :include option again!
36
65
  email: mat@patch.com
37
66
  executables: []
@@ -42,14 +71,13 @@ extra_rdoc_files: []
42
71
 
43
72
  files:
44
73
  - rails/init.rb
74
+ - lib/eager_record/eager_preloading.rb
45
75
  - lib/eager_record/scoped_preloading.rb
46
- - lib/eager_record/version.rb
47
76
  - lib/eager_record/unmarshallable.rb
48
- - lib/eager_record/eager_preloading.rb
77
+ - lib/eager_record/version.rb
49
78
  - lib/eager_record.rb
50
79
  - README.rdoc
51
80
  - History.txt
52
- has_rdoc: true
53
81
  homepage: http://github.com/outoftime/eager_record
54
82
  licenses: []
55
83
 
@@ -79,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
107
  requirements: []
80
108
 
81
109
  rubyforge_project: eager_record
82
- rubygems_version: 1.3.7
110
+ rubygems_version: 1.8.25
83
111
  signing_key:
84
112
  specification_version: 3
85
113
  summary: Automatic association preloading for ActiveRecord collections.