eager_record 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,15 +41,17 @@ module EagerRecord
41
41
  def load_target_with_eager_preloading
42
42
  return nil unless defined?(@loaded)
43
43
 
44
- if !loaded? and (!@owner.new_record? || foreign_key_present)
45
- if originating_collection = @owner.instance_variable_get(:@originating_collection)
46
- association_name = @reflection.name
47
- @owner.class.__send__(:preload_associations, originating_collection, association_name)
48
- new_association = @owner.__send__(:association_instance_get, association_name)
49
- if new_association && __id__ != new_association.__id__ && new_association.loaded?
50
- @target = new_association.target
51
- @loaded = true
52
- return
44
+ if @owner.read_attribute(@reflection.primary_key_name)
45
+ if !loaded? and (!@owner.new_record? || foreign_key_present)
46
+ if originating_collection = @owner.instance_variable_get(:@originating_collection)
47
+ association_name = @reflection.name
48
+ @owner.class.__send__(:preload_associations, originating_collection, association_name)
49
+ new_association = @owner.__send__(:association_instance_get, association_name)
50
+ if new_association && __id__ != new_association.__id__ && new_association.loaded?
51
+ @target = new_association.target
52
+ @loaded = true
53
+ return
54
+ end
53
55
  end
54
56
  end
55
57
  end
@@ -1,3 +1,3 @@
1
1
  module EagerRecord
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
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: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mat Brown
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-21 00:00:00 -04:00
18
+ date: 2011-01-04 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,9 +42,9 @@ extra_rdoc_files: []
42
42
 
43
43
  files:
44
44
  - rails/init.rb
45
+ - lib/eager_record/scoped_preloading.rb
45
46
  - lib/eager_record/version.rb
46
47
  - lib/eager_record/unmarshallable.rb
47
- - lib/eager_record/scoped_preloading.rb
48
48
  - lib/eager_record/eager_preloading.rb
49
49
  - lib/eager_record.rb
50
50
  - README.rdoc