Module: Mongoid::QueryCache::Base

Defined in:
lib/mongoid/query_cache.rb

Overview

Included to add behaviour for clearing out the query cache on certain operations.

Since:

  • 4.0.0

Instance Method Summary collapse

Instance Method Details

#alias_query_cache_clear(*method_names) ⇒ Object

Since:

  • 4.0.0



163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/mongoid/query_cache.rb', line 163

def alias_query_cache_clear(*method_names)
  method_names.each do |method_name|
    class_eval <<-CODE, __FILE__, __LINE__ + 1
        def #{method_name}_with_clear_cache(*args)
          QueryCache.clear_cache
          #{method_name}_without_clear_cache(*args)
        end
      CODE

    alias_method_chain method_name, :clear_cache
  end
end