Class: R10K::Util::Attempt Private
- Inherits:
-
Object
- Object
- R10K::Util::Attempt
- Defined in:
- lib/r10k/util/attempt.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Attempt a series of dependent nested tasks and cleanly handle errors.
Constant Summary
Constants included from Logging
Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP
Instance Attribute Summary collapse
- #status ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(initial, opts = {}) ⇒ Attempt
constructor
private
A new instance of Attempt.
- #ok? ⇒ Boolean private
-
#run ⇒ Object
private
Run this attempt to completion.
-
#try {|The| ... } ⇒ Object
private
Add another action to take for this attempt.
Methods included from Logging
add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Constructor Details
#initialize(initial, opts = {}) ⇒ Attempt
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Attempt.
21 22 23 24 25 26 |
# File 'lib/r10k/util/attempt.rb', line 21 def initialize(initial, opts = {}) @initial = initial @tries = [] @status = :notrun setopts(opts, {:trace => :self}) end |
Instance Attribute Details
#status ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/r10k/util/attempt.rb', line 19 def status @status end |
Instance Method Details
#ok? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 |
# File 'lib/r10k/util/attempt.rb', line 52 def ok? @status == :ok end |
#run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
determine the structure of the ret
Run this attempt to completion.
32 33 34 35 36 37 |
# File 'lib/r10k/util/attempt.rb', line 32 def run @status = :running result = apply(@initial, @tries) @status = :ok if @status == :running result end |
#try {|The| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add another action to take for this attempt
47 48 49 50 |
# File 'lib/r10k/util/attempt.rb', line 47 def try(&block) @tries << block self end |