Class: ActiveRecord::ExplainRegistry

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

Overview

This is a thread locals registry for EXPLAIN. For example

ActiveRecord::ExplainRegistry.queries

returns the collected queries local to the current thread.

Defined Under Namespace

Classes: Subscriber

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExplainRegistry



68
69
70
# File 'lib/active_record/explain_registry.rb', line 68

def initialize
  reset
end

Instance Attribute Details

#collectObject

Returns the value of attribute collect.



65
66
67
# File 'lib/active_record/explain_registry.rb', line 65

def collect
  @collect
end

#queriesObject (readonly)

Returns the value of attribute queries.



66
67
68
# File 'lib/active_record/explain_registry.rb', line 66

def queries
  @queries
end

Instance Method Details

#collect?Boolean



77
78
79
# File 'lib/active_record/explain_registry.rb', line 77

def collect?
  @collect
end

#resetObject



81
82
83
84
# File 'lib/active_record/explain_registry.rb', line 81

def reset
  @collect = false
  @queries = []
end

#startObject



72
73
74
75
# File 'lib/active_record/explain_registry.rb', line 72

def start
  Subscriber.ensure_subscribed
  @collect = true
end