Class: CfnFlow::EventPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/cfn_flow/event_presenter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#eventObject

Instance methods



24
25
26
# File 'lib/cfn_flow/event_presenter.rb', line 24

def event
  @event
end

Class Method Details

.headerObject



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_idsObject

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_sObject



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