aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-26 13:53:56 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-26 13:53:56 -0700
commit1d6bb77636aeec734079f63e1c14429b34e79ed9 (patch)
tree6e0f0930c1947d5f1d9ff1e95e12ca5992c25ff8 /activerecord/lib/active_record/relation.rb
parented1a775da3921797fc74d69bb392b2cc0ad57ef1 (diff)
downloadrails-1d6bb77636aeec734079f63e1c14429b34e79ed9.tar.gz
rails-1d6bb77636aeec734079f63e1c14429b34e79ed9.tar.bz2
rails-1d6bb77636aeec734079f63e1c14429b34e79ed9.zip
Inject the `PredicateBuilder` into the `Relation` instance
Construction of relations can be a hotspot, we don't want to create one of these in the constructor. This also allows us to do more expensive things in the predicate builder's constructor, since it's created once per AR::Base subclass
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index daafb0b645..2f067d867c 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -16,17 +16,17 @@ module ActiveRecord
include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches, Explain, Delegation
- attr_reader :table, :klass, :loaded
+ attr_reader :table, :klass, :loaded, :predicate_builder
alias :model :klass
alias :loaded? :loaded
- def initialize(klass, table, values = {})
+ def initialize(klass, table, predicate_builder, values = {})
@klass = klass
@table = table
@values = values
@offsets = {}
@loaded = false
- @predicate_builder = PredicateBuilder.new(klass, table)
+ @predicate_builder = predicate_builder
end
def initialize_copy(other)
@@ -633,10 +633,6 @@ module ActiveRecord
"#<#{self.class.name} [#{entries.join(', ')}]>"
end
- protected
-
- attr_reader :predicate_builder
-
private
def exec_queries