AS::Concern is not really needed for AR::Explain

This commit is contained in:
Xavier Noria 2011-12-16 12:12:05 -08:00
parent 05316ba127
commit 0065f37826
3 changed files with 74 additions and 76 deletions

View File

@ -699,7 +699,7 @@ module ActiveRecord #:nodoc:
include Associations
include IdentityMap
include ActiveModel::SecurePassword
include Explain
extend Explain
# AutosaveAssociation needs to be included before Transactions, because we want
# #save_with_autosave_associations to be wrapped inside a transaction.

View File

@ -1,17 +1,16 @@
require 'active_support/concern'
require 'active_support/core_ext/class/attribute'
module ActiveRecord
module Explain
extend ActiveSupport::Concern
included do
def self.extended(base)
base.class_eval do
# If a query takes longer than these many seconds we log its query plan
# automatically. nil disables this feature.
class_attribute :auto_explain_threshold_in_seconds, :instance_writer => false
self.auto_explain_threshold_in_seconds = nil
end
end
module ClassMethods
# If auto explain is enabled, this method triggers EXPLAIN logging for the
# queries triggered by the block if it takes more than the threshold as a
# whole. That is, the threshold is not checked against each individual
@ -82,4 +81,3 @@ module ActiveRecord
end
end
end
end

View File

@ -9,7 +9,7 @@ module ActiveRecord
MULTI_VALUE_METHODS = [:select, :group, :order, :joins, :where, :having, :bind]
SINGLE_VALUE_METHODS = [:limit, :offset, :lock, :readonly, :from, :reorder, :reverse_order, :uniq]
include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches, Explain::ClassMethods, Delegation
include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches, Explain, Delegation
attr_reader :table, :klass, :loaded
attr_accessor :extensions, :default_scoped