Class: ActiveRecord::QueryCache::BodyProxy

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/query_cache.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(original_cache_value, target, connection_id) ⇒ BodyProxy

Returns a new instance of BodyProxy.



31
32
33
34
35
# File 'activerecord/lib/active_record/query_cache.rb', line 31

def initialize(original_cache_value, target, connection_id)
  @original_cache_value = original_cache_value
  @target               = target
  @connection_id        = connection_id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



37
38
39
# File 'activerecord/lib/active_record/query_cache.rb', line 37

def method_missing(method_sym, *arguments, &block)
  @target.send(method_sym, *arguments, &block)
end

Instance Method Details

#closeObject



49
50
51
52
53
54
55
56
57
# File 'activerecord/lib/active_record/query_cache.rb', line 49

def close
  @target.close if @target.respond_to?(:close)
ensure
  ActiveRecord::Base.connection_id = @connection_id
  ActiveRecord::Base.connection.clear_query_cache
  unless @original_cache_value
    ActiveRecord::Base.connection.disable_query_cache!
  end
end

#each(&block) ⇒ Object



45
46
47
# File 'activerecord/lib/active_record/query_cache.rb', line 45

def each(&block)
  @target.each(&block)
end

#respond_to?(method_sym, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'activerecord/lib/active_record/query_cache.rb', line 41

def respond_to?(method_sym, include_private = false)
  super || @target.respond_to?(method_sym)
end