Class: ActiveRecord::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/simple_explain/relation.rb

Instance Method Summary collapse

Instance Method Details

#explainObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/active_record/simple_explain/relation.rb', line 9

def explain
  adapter = ActiveRecord::Base.connection.class.to_s.split(/::/).last

  exp = proc { SimpleExplain.new(adapter, to_sql).display }

  if method_defined? :explain_org
    if adapter == 'sqlite3'
      exp.call
    else
      explain_org
    end
  else
    exp.call
  end
end

#explain_orgObject



7
# File 'lib/active_record/simple_explain/relation.rb', line 7

alias_method :explain_org, :explain