Module: Axn::Util::ExecutionContext
- Defined in:
- lib/axn/util/execution_context.rb
Class Method Summary collapse
-
.background? ⇒ Boolean
Determines if code is currently running within a background job context.
-
.console? ⇒ Boolean
Determines if code is currently running in an interactive console (IRB, Pry, Rails console).
Class Method Details
.background? ⇒ Boolean
Determines if code is currently running within a background job context. Checks all registered async adapters to see if any report running in background.
17 18 19 20 21 22 23 |
# File 'lib/axn/util/execution_context.rb', line 17 def background? Axn::Async::Adapters.all.values.any? do |adapter| adapter.respond_to?(:_running_in_background?) && adapter._running_in_background? end rescue StandardError false end |
.console? ⇒ Boolean
Determines if code is currently running in an interactive console (IRB, Pry, Rails console). Used to skip visual separators in console output since the prompt already provides separation.
29 30 31 |
# File 'lib/axn/util/execution_context.rb', line 29 def console? defined?(Rails::Console) || defined?(IRB) || defined?(Pry) end |