aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-02-13 11:03:00 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-02-13 11:03:00 -0800
commitf9e4c3c7c0c4152b62fe9202a9d12262884bb118 (patch)
tree450237eb4aee6d2d12c946c5de5005d48a8cf0ec /activerecord/lib/active_record/associations
parent9ec42f963feea891d7066843c17cd46963440e25 (diff)
downloadrails-f9e4c3c7c0c4152b62fe9202a9d12262884bb118.tar.gz
rails-f9e4c3c7c0c4152b62fe9202a9d12262884bb118.tar.bz2
rails-f9e4c3c7c0c4152b62fe9202a9d12262884bb118.zip
speed up the collection proxy reader method, but slow down the constructor
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 89b7945c78..03ca00fa70 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -24,6 +24,10 @@ module ActiveRecord
# If you need to work on all current children, new and existing records,
# +load_target+ and the +loaded+ flag are your friends.
class CollectionAssociation < Association #:nodoc:
+ def initialize(owner, reflection)
+ super
+ @proxy = CollectionProxy.create(klass, self)
+ end
# Implements the reader method, e.g. foo.items for Foo.has_many :items
def reader(force_reload = false)
@@ -33,7 +37,7 @@ module ActiveRecord
reload
end
- @proxy ||= CollectionProxy.create(klass, self)
+ @proxy
end
# Implements the writer method, e.g. foo.items= for Foo.has_many :items