Relation#explain needs to be able to collect the queries regardless of
whether auto explain is enabled. This method serves that purpose.
# File activerecord/lib/active_record/explain.rb, line 47
def collecting_queries_for_explain # :nodoc:
current = Thread.current
original, current[:available_queries_for_explain] = current[:available_queries_for_explain], []
return yield, current[:available_queries_for_explain]
ensure
# Note that the return value above does not depend on this assigment.
current[:available_queries_for_explain] = original
end