lib/new_relic/agent/instrumentation/active_record_subscriber.rb
# The cached? method is dynamically defined based on ActiveRecord version.
# This file can and often is required before ActiveRecord is loaded. For
# that reason we define the cache? method in initialize. The behavior
# difference is that AR 5.1 includes a key in the payload to check,
# where older versions set the :name to CACHE.
The cached. method is dynamically defined based on ActiveRecord version.
This file can and often is required before ActiveRecord is loaded. For
that reason we define the cache. method in initialize. The behavior
difference is that AR 5.1 includes a key in the payload to check,
where older versions set the :name to CACHE.
The cached . method is dynamically defined based on ActiveRecord version . This file can and often is required before ActiveRecord is loaded . For that reason we define the cache . method in initialize . The behavior difference is that AR 5 . 1 includes a key in the payload to check where older versions set the : name to CACHE .
def define_cachedp_method
          return if defined?(cached?)
          if ::ActiveRecord::VERSION::STRING >= "5.1.0"
            def cached?(payload)
              payload.fetch(:cached, false)
            end
          else
            def cached?(payload)
              payload[:name] == CACHED_QUERY_NAME
            end
          end
        end
def define_cachedp_method return if defined? ( cached? ) if :: ActiveRecord :: VERSION :: STRING >= "5.1.0" def cached? ( payload ) payload . fetch ( :cached , false ) end else def cached? ( payload ) payload [ :name ] == CACHED_QUERY_NAME end end end
The cached?
The cached?
# we don't expect this to be called more than once, but we're being # defensive.