Class: OpsDeploy::Waiter
- Inherits:
-
Thread
- Object
- Thread
- OpsDeploy::Waiter
- Defined in:
- lib/ops_deploy/waiter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#data ⇒ Object
Returns the value of attribute data.
-
#end_when ⇒ Object
Returns the value of attribute end_when.
Instance Method Summary collapse
-
#initialize(&task) ⇒ Waiter
constructor
A new instance of Waiter.
Constructor Details
#initialize(&task) ⇒ Waiter
Returns a new instance of Waiter.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ops_deploy/waiter.rb', line 4 def initialize(&task) @task = task super() { error = nil begin until false @data = @task.call break if @end_when.call(@data) sleep 5 end rescue StandardError => e error = e end @callback.call(@data, error) if @callback @data } end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
2 3 4 |
# File 'lib/ops_deploy/waiter.rb', line 2 def callback @callback end |
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/ops_deploy/waiter.rb', line 2 def data @data end |
#end_when ⇒ Object
Returns the value of attribute end_when.
2 3 4 |
# File 'lib/ops_deploy/waiter.rb', line 2 def end_when @end_when end |