Class: UltraMarathon::BaseRunner
- Includes:
- Callbacks, Instrumentation, Logging
- Defined in:
- lib/ultra_marathon/base_runner.rb
Direct Known Subclasses
Constant Summary collapse
- RUN_INSTRUMENTATION_NAME =
'__run!'.freeze
Instance Attribute Summary collapse
-
#success ⇒ Object
Returns the value of attribute success.
Class Method Summary collapse
-
.new(*args, &block) ⇒ Object
Public Class Methods.
Instance Method Summary collapse
-
#reset ⇒ Object
Resets success to being true, unsets the failed sub_runners to [], and sets the unrun sub_runners to be the uncompleted/failed ones.
-
#run! ⇒ Object
Runs the run block safely in the context of the instance.
- #run_instrumentation ⇒ Object
- #success? ⇒ Boolean
Methods included from Contexticution
Methods included from Instrumentation
Methods included from Logging
Instance Attribute Details
#success ⇒ Object
Returns the value of attribute success.
12 13 14 |
# File 'lib/ultra_marathon/base_runner.rb', line 12 def success @success end |
Class Method Details
.new(*args, &block) ⇒ Object
Public Class Methods
21 22 23 24 25 |
# File 'lib/ultra_marathon/base_runner.rb', line 21 def self.new(*args, &block) super(*args, &block).tap do |instance| instance.send(:invoke_after_initialize_callbacks) end end |
Instance Method Details
#reset ⇒ Object
Resets success to being true, unsets the failed sub_runners to [], and sets the unrun sub_runners to be the uncompleted/failed ones
54 55 56 57 58 59 |
# File 'lib/ultra_marathon/base_runner.rb', line 54 def reset reset_failed_runners @success = nil invoke_on_reset_callbacks self end |
#run! ⇒ Object
Runs the run block safely in the context of the instance
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ultra_marathon/base_runner.rb', line 30 def run! if unrun_sub_runners.any? instrument RUN_INSTRUMENTATION_NAME do begin self.success = nil invoke_before_run_callbacks instrument(:__run_unrun_sub_runners) { run_unrun_sub_runners } # If any of the sub runners explicitly set the success flag, don't override it self.success = failed_sub_runners.empty? if self.success.nil? rescue StandardError => error invoke_on_error_callbacks(error) end end invoke_after_run_callbacks end self end |
#run_instrumentation ⇒ Object
61 62 63 |
# File 'lib/ultra_marathon/base_runner.rb', line 61 def run_instrumentation instrumentations[RUN_INSTRUMENTATION_NAME] end |
#success? ⇒ Boolean
48 49 50 |
# File 'lib/ultra_marathon/base_runner.rb', line 48 def success? !!success end |