Class: Convection::Model::Event

Inherits:
Object
  • Object
show all
Extended by:
Mixin::Colorize
Defined in:
lib/convection/model/event.rb

Overview

Wrap events with some smarts

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin::Colorize

colorize

Constructor Details

#initialize(name, message, level = :info, attributes = {}) ⇒ Event

Returns a new instance of Event



43
44
45
46
47
48
# File 'lib/convection/model/event.rb', line 43

def initialize(name, message, level = :info, attributes = {})
  @name = name
  @message = message
  @level = level
  @attributes = attributes
end

Instance Attribute Details

#levelObject

Returns the value of attribute level



14
15
16
# File 'lib/convection/model/event.rb', line 14

def level
  @level
end

#messageObject

Returns the value of attribute message



13
14
15
# File 'lib/convection/model/event.rb', line 13

def message
  @message
end

#nameObject

Returns the value of attribute name



12
13
14
# File 'lib/convection/model/event.rb', line 12

def name
  @name
end

#timestampObject

Returns the value of attribute timestamp



15
16
17
# File 'lib/convection/model/event.rb', line 15

def timestamp
  @timestamp
end

Class Method Details

.from_cf(event) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/convection/model/event.rb', line 26

def from_cf(event)
  Event.new(event.resource_status.downcase,
            "#{ event.logical_resource_id }: (#{ event.resource_type }/"\
            "#{ event.physical_resource_id}) #{ event.resource_status_reason }",
            event.resource_status,
            :event_id => event.event_id,
            :logical_resource_id => event.logical_resource_id,
            :physical_resource_id => event.physical_resource_id,
            :resource_properties => event.resource_properties,
            :resource_status_reason => event.resource_status_reason,
            :resource_type => event.resource_type,
            :stack_id => event.stack_id,
            :stack_name => event.stack_name,
            :timestamp => event.timestamp)
end

Instance Method Details

#[](attr) ⇒ Object



50
51
52
# File 'lib/convection/model/event.rb', line 50

def [](attr)
  @attributes[attr]
end

#[]=(attr, value) ⇒ Object



54
55
56
# File 'lib/convection/model/event.rb', line 54

def []=(attr, value)
  @attributes[attr] = value
end

#to_thorObject



58
59
60
# File 'lib/convection/model/event.rb', line 58

def to_thor
  [name.downcase, message, color]
end