module Kernel
Public Instance Methods
ae(query)
click to toggle source
# File lib/awesome_explain/kernel.rb, line 2 def ae(query) return AwesomeExplain::Renderers::Mongoid.new(query).print if mongoid_query?(query) return AwesomeExplain::Renderers::ActiveRecord.new(query).print if active_record_query?(query) query end
analyze(&block)
click to toggle source
# File lib/awesome_explain/kernel.rb, line 9 def analyze(&block) ::AwesomeExplain::MongoiddInsights.analyze(&block) end
analyze_ar(options = {}, &block)
click to toggle source
# File lib/awesome_explain/kernel.rb, line 13 def analyze_ar(options = {}, &block) Thread.current['ae_analyze'] = true Thread.current['ae_source'] = 'console' ::AwesomeExplain::Insights::ActiveRecordInsights.analyze(options, &block) end
Private Instance Methods
active_record_query?(query)
click to toggle source
# File lib/awesome_explain/kernel.rb, line 27 def active_record_query?(query) defined?(ActiveRecord::Relation) && query.is_a?(ActiveRecord::Relation) end
mongoid_query?(query)
click to toggle source
# File lib/awesome_explain/kernel.rb, line 21 def mongoid_query?(query) defined?(Mongo::Collection::View::Aggregation) && defined?(Mongoid::Criteria) && (query.is_a?(Mongo::Collection::View::Aggregation) || query.is_a?(Mongoid::Criteria)) end