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) ⇒ BodyProxy

Returns a new instance of BodyProxy.



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

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



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

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

Instance Method Details

#closeObject



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

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

#each(&block) ⇒ Object



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

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

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

Returns:

  • (Boolean)


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

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