eager_record 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module EagerRecord
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/eager_record.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'rubygems'
1
+ 'rubygems'
2
2
  require 'active_record'
3
3
  require 'digest'
4
4
 
@@ -81,7 +81,12 @@ module EagerRecord
81
81
  if originating_collection = @owner.instance_variable_get(:@originating_collection)
82
82
  association_name = @reflection.name
83
83
  @owner.class.__send__(:preload_associations, originating_collection, association_name)
84
- return @target if loaded?
84
+ new_association = @owner.__send__(:association_instance_get, association_name)
85
+ if new_association && __id__ != new_association.__id__ && new_association.loaded?
86
+ @target = new_association.target
87
+ @loaded = true
88
+ return
89
+ end
85
90
  end
86
91
  end
87
92
  load_target_without_eager_preloading
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mat Brown
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-03 00:00:00 -04:00
17
+ date: 2010-05-04 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency