Class: Stackup::StackWatcher
- Inherits:
-
Object
- Object
- Stackup::StackWatcher
- Defined in:
- lib/stackup/stack_watcher.rb
Overview
A stack event observer.
Keeps track of previously processed events, and yields the new ones.
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
-
#each_new_event ⇒ Object
Yield all events since the last call.
-
#initialize(stack) ⇒ StackWatcher
constructor
A new instance of StackWatcher.
-
#zero ⇒ Object
Consume all new events.
Constructor Details
#initialize(stack) ⇒ StackWatcher
Returns a new instance of StackWatcher.
11 12 13 14 |
# File 'lib/stackup/stack_watcher.rb', line 11 def initialize(stack) @stack = stack @processed_event_ids = Set.new end |
Instance Attribute Details
#stack ⇒ Object
Returns the value of attribute stack.
16 17 18 |
# File 'lib/stackup/stack_watcher.rb', line 16 def stack @stack end |
Instance Method Details
#each_new_event ⇒ Object
Yield all events since the last call
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/stackup/stack_watcher.rb', line 20 def each_new_event # rubocop:disable Lint/HandleExceptions buffer = [] stack.events.each do |event| break if @processed_event_ids.include?(event.event_id) buffer.unshift(event) end buffer.each do |event| yield event if block_given? @processed_event_ids.add(event.event_id) end rescue Aws::CloudFormation::Errors::ValidationError end |
#zero ⇒ Object
Consume all new events
36 37 38 39 |
# File 'lib/stackup/stack_watcher.rb', line 36 def zero each_new_event nil end |