Class: ActiveRecord::AsynchronousQueriesTracker
- Inherits:
-
Object
- Object
- ActiveRecord::AsynchronousQueriesTracker
- Defined in:
- lib/active_record/asynchronous_queries_tracker.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Session
Class Method Summary collapse
- .complete(asynchronous_queries_tracker) ⇒ Object
- .install_executor_hooks(executor = ActiveSupport::Executor) ⇒ Object
- .run ⇒ Object
Instance Method Summary collapse
- #current_session ⇒ Object
- #finalize_session(wait = false) ⇒ Object
-
#initialize ⇒ AsynchronousQueriesTracker
constructor
A new instance of AsynchronousQueriesTracker.
- #start_session ⇒ Object
Constructor Details
#initialize ⇒ AsynchronousQueriesTracker
Returns a new instance of AsynchronousQueriesTracker.
45 46 47 |
# File 'lib/active_record/asynchronous_queries_tracker.rb', line 45 def initialize @stack = [] end |
Class Method Details
.complete(asynchronous_queries_tracker) ⇒ Object
40 41 42 |
# File 'lib/active_record/asynchronous_queries_tracker.rb', line 40 def complete(asynchronous_queries_tracker) asynchronous_queries_tracker.finalize_session end |
.install_executor_hooks(executor = ActiveSupport::Executor) ⇒ Object
32 33 34 |
# File 'lib/active_record/asynchronous_queries_tracker.rb', line 32 def install_executor_hooks(executor = ActiveSupport::Executor) executor.register_hook(self) end |
.run ⇒ Object
36 37 38 |
# File 'lib/active_record/asynchronous_queries_tracker.rb', line 36 def run ActiveRecord::Base.asynchronous_queries_tracker.tap(&:start_session) end |
Instance Method Details
#current_session ⇒ Object
49 50 51 |
# File 'lib/active_record/asynchronous_queries_tracker.rb', line 49 def current_session @stack.last or raise ActiveRecordError, "Can't perform asynchronous queries without a query session" end |
#finalize_session(wait = false) ⇒ Object
58 59 60 61 62 |
# File 'lib/active_record/asynchronous_queries_tracker.rb', line 58 def finalize_session(wait = false) session = @stack.pop session&.finalize(wait) self end |