diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-10 16:58:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-10 16:58:15 -0700 |
commit | 47037b648d1b56470dba35798fc5e30f1143eb95 (patch) | |
tree | c62e3036b80b63b5f336cc1e581ab002baec7a75 /activerecord | |
parent | 90c9a09ff70388b32b9c9afca4ae998b99fd2d1f (diff) | |
download | rails-47037b648d1b56470dba35798fc5e30f1143eb95.tar.gz rails-47037b648d1b56470dba35798fc5e30f1143eb95.tar.bz2 rails-47037b648d1b56470dba35798fc5e30f1143eb95.zip |
eagerly build the relation object
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/statement_cache.rb | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb index 1a2ff23013..d2a0c6f618 100644 --- a/activerecord/lib/active_record/statement_cache.rb +++ b/activerecord/lib/active_record/statement_cache.rb @@ -76,15 +76,13 @@ module ActiveRecord def initialize(block = Proc.new) @mutex = Mutex.new - @relation = nil @binds = nil - @block = block @query_builder = nil - @params = Params.new + @relation = block.call Params.new end def execute(params) - rel = relation @params + rel = @relation arel = rel.arel klass = rel.klass @@ -108,9 +106,5 @@ module ActiveRecord @query_builder ||= connection.cacheable_query(arel) } end - - def relation(values) - @relation || @mutex.synchronize { @relation ||= @block.call(values) } - end end end |