Class: CfnFlow::EventPresenter
- Inherits:
-
Object
- Object
- CfnFlow::EventPresenter
- Defined in:
- lib/cfn_flow/event_presenter.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
Instance methods.
Class Method Summary collapse
- .header ⇒ Object
-
.present(raw_events, &block) ⇒ Object
Yields each new event present to
block. -
.seen_event_ids ⇒ Object
Class methods.
Instance Method Summary collapse
-
#initialize(event) ⇒ EventPresenter
constructor
A new instance of EventPresenter.
- #to_s ⇒ Object
Constructor Details
#initialize(event) ⇒ EventPresenter
Returns a new instance of EventPresenter.
25 26 27 28 |
# File 'lib/cfn_flow/event_presenter.rb', line 25 def initialize(event) @event = event self.class.seen_event_ids << event.id end |
Instance Attribute Details
#event ⇒ Object
Instance methods
24 25 26 |
# File 'lib/cfn_flow/event_presenter.rb', line 24 def event @event end |
Class Method Details
.header ⇒ Object
18 19 20 |
# File 'lib/cfn_flow/event_presenter.rb', line 18 def self.header %w(status logical_resource_id resource_type reason) * "\t" end |
.present(raw_events, &block) ⇒ Object
Yields each new event present to block
12 13 14 15 16 |
# File 'lib/cfn_flow/event_presenter.rb', line 12 def self.present(raw_events, &block) raw_events.to_a.reverse.sort_by(&:timestamp). reject {|e| seen_event_ids.include?(e.id) }. map {|e| yield new(e) } end |
.seen_event_ids ⇒ Object
Class methods
7 8 9 |
# File 'lib/cfn_flow/event_presenter.rb', line 7 def self.seen_event_ids @seen_event_ids ||= Set.new end |
Instance Method Details
#to_s ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/cfn_flow/event_presenter.rb', line 30 def to_s [ event.resource_status, event.logical_resource_id, event.resource_type, event.resource_status_reason ].compact * "\t" end |