aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-09-24 11:36:14 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-09-24 11:36:14 -0700
commit2075f39d726cef361170218fd16421fc52bed5a8 (patch)
tree77de22bb625bf26927cdebb2d2c399c5d0707a02 /activerecord/lib/active_record/associations/preloader
parentb93d09dbc59b3b85e7208cd57c92be9d86fd51df (diff)
downloadrails-2075f39d726cef361170218fd16421fc52bed5a8.tar.gz
rails-2075f39d726cef361170218fd16421fc52bed5a8.tar.bz2
rails-2075f39d726cef361170218fd16421fc52bed5a8.zip
eliminate the `loaded?` conditional
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader')
-rw-r--r--activerecord/lib/active_record/associations/preloader/association.rb7
-rw-r--r--activerecord/lib/active_record/associations/preloader/through_association.rb4
2 files changed, 1 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb
index cdf4a27341..d02384e221 100644
--- a/activerecord/lib/active_record/associations/preloader/association.rb
+++ b/activerecord/lib/active_record/associations/preloader/association.rb
@@ -17,7 +17,6 @@ module ActiveRecord
@owners_by_key = nil
@type_caster = IDENTITY_CASTER
@associated_records_by_owner = nil
- @loaded = false
end
def run(preloader)
@@ -74,15 +73,9 @@ module ActiveRecord
@associated_records_by_owner.values.flatten
end
- def loaded?
- @loaded
- end
-
private
def associated_records_by_owner(preloader)
- @loaded = true
-
return @associated_records_by_owner if @associated_records_by_owner
owners_map = owners_by_key
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb
index 0c0501fd58..15fdba51f3 100644
--- a/activerecord/lib/active_record/associations/preloader/through_association.rb
+++ b/activerecord/lib/active_record/associations/preloader/through_association.rb
@@ -12,8 +12,6 @@ module ActiveRecord
end
def associated_records_by_owner(preloader)
- @loaded = true
-
return @associated_records_by_owner if @associated_records_by_owner
preloader.preload(owners,
@@ -54,7 +52,7 @@ module ActiveRecord
r.send(source_reflection.name)
}.compact
- if pl && pl.loaded?
+ if pl
loaded_records = pl.preloaded_records
i = 0
record_index = loaded_records.each_with_object({}) { |r,indexes|