Class: Dogapi::Event
- Inherits:
-
Object
- Object
- Dogapi::Event
- Defined in:
- lib/dogapi/event.rb
Overview
Metadata class for storing the details of an event
Instance Attribute Summary collapse
-
#aggregation_key ⇒ Object
readonly
Returns the value of attribute aggregation_key.
-
#date_happened ⇒ Object
readonly
Returns the value of attribute date_happened.
-
#msg_text ⇒ Object
readonly
Returns the value of attribute msg_text.
-
#msg_title ⇒ Object
readonly
Returns the value of attribute msg_title.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(msg_text, options = {}) ⇒ Event
constructor
Optional arguments: :date_happened => time in seconds since the epoch (defaults to now) :msg_title => String :priority => String :parent => event ID (integer) :tags => array of Strings :event_object => String :alert_type => ‘success’, ‘error’ :event_type => String :source_type_name => String :aggregation_key => String.
-
#to_hash ⇒ Object
Copy and pasted from the internets stackoverflow.com/a/5031637/25276.
Constructor Details
#initialize(msg_text, options = {}) ⇒ Event
Optional arguments:
:date_happened => time in seconds since the epoch (defaults to now)
:msg_title => String
:priority => String
:parent => event ID (integer)
:tags => array of Strings
:event_object => String
:alert_type => 'success', 'error'
:event_type => String
:source_type_name => String
:aggregation_key => String
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dogapi/event.rb', line 33 def initialize(msg_text, = {}) defaults = { :date_happened => Time.now.to_i, :msg_title => '', :priority => "normal", :parent => nil, :tags => [], :aggregation_key => nil } = defaults.merge() @msg_text = msg_text @date_happened = [:date_happened] @msg_title = [:msg_title] @priority = [:priority] @parent = [:parent] @tags = [:tags] @aggregation_key = [:event_object] || [:aggregation_key] @alert_type = [:alert_type] @event_type = [:event_type] @source_type_name = [:source_type_name] end |
Instance Attribute Details
#aggregation_key ⇒ Object (readonly)
Returns the value of attribute aggregation_key.
14 15 16 |
# File 'lib/dogapi/event.rb', line 14 def aggregation_key @aggregation_key end |
#date_happened ⇒ Object (readonly)
Returns the value of attribute date_happened.
14 15 16 |
# File 'lib/dogapi/event.rb', line 14 def date_happened @date_happened end |
#msg_text ⇒ Object (readonly)
Returns the value of attribute msg_text.
14 15 16 |
# File 'lib/dogapi/event.rb', line 14 def msg_text @msg_text end |
#msg_title ⇒ Object (readonly)
Returns the value of attribute msg_title.
14 15 16 |
# File 'lib/dogapi/event.rb', line 14 def msg_title @msg_title end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
14 15 16 |
# File 'lib/dogapi/event.rb', line 14 def parent @parent end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
14 15 16 |
# File 'lib/dogapi/event.rb', line 14 def priority @priority end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
14 15 16 |
# File 'lib/dogapi/event.rb', line 14 def @tags end |
Instance Method Details
#to_hash ⇒ Object
Copy and pasted from the internets stackoverflow.com/a/5031637/25276
58 59 60 61 62 |
# File 'lib/dogapi/event.rb', line 58 def to_hash hash = {} instance_variables.each { |var| hash[var.to_s[1..-1].to_sym] = instance_variable_get(var) } hash end |