Class: Notifu::Model::Event
- Includes:
- Util
- Defined in:
- lib/notifu/model/event.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#api_endpoint ⇒ Object
readonly
Returns the value of attribute api_endpoint.
-
#aspiring_code ⇒ Object
readonly
Returns the value of attribute aspiring_code.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#datacenter ⇒ Object
readonly
Returns the value of attribute datacenter.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#notifu_id ⇒ Object
readonly
Returns the value of attribute notifu_id.
-
#occurrences_count ⇒ Object
readonly
Returns the value of attribute occurrences_count.
-
#occurrences_trigger ⇒ Object
readonly
Returns the value of attribute occurrences_trigger.
-
#playbook ⇒ Object
readonly
Returns the value of attribute playbook.
-
#process_result ⇒ Object
Returns the value of attribute process_result.
-
#refresh ⇒ Object
readonly
Returns the value of attribute refresh.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#sgs ⇒ Object
readonly
Returns the value of attribute sgs.
-
#time_created ⇒ Object
readonly
Returns the value of attribute time_created.
-
#time_last_event ⇒ Object
readonly
Returns the value of attribute time_last_event.
-
#time_last_notified ⇒ Object
readonly
Returns the value of attribute time_last_notified.
-
#unsilence ⇒ Object
readonly
Returns the value of attribute unsilence.
Instance Method Summary collapse
- #data ⇒ Object
- #group_sla ⇒ Object
-
#initialize(args) ⇒ Event
constructor
A new instance of Event.
- #update_process_result!(obj) ⇒ Object
Methods included from Util
Constructor Details
#initialize(args) ⇒ Event
Returns a new instance of Event.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/notifu/model/event.rb', line 28 def initialize args payload = args.first payload.each { |name, value| instance_variable_set("@#{name}", value) } @time_last_notified = Hash.new.to_json.to_s @time_created = self.time_last_event @aspiring_code = self.code @occurrences_trigger ||= 1 @refresh ||= nil @unsilence ||= true end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
17 18 19 |
# File 'lib/notifu/model/event.rb', line 17 def action @action end |
#address ⇒ Object (readonly)
Returns the value of attribute address.
8 9 10 |
# File 'lib/notifu/model/event.rb', line 8 def address @address end |
#api_endpoint ⇒ Object (readonly)
Returns the value of attribute api_endpoint.
22 23 24 |
# File 'lib/notifu/model/event.rb', line 22 def api_endpoint @api_endpoint end |
#aspiring_code ⇒ Object (readonly)
Returns the value of attribute aspiring_code.
19 20 21 |
# File 'lib/notifu/model/event.rb', line 19 def aspiring_code @aspiring_code end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
18 19 20 |
# File 'lib/notifu/model/event.rb', line 18 def code @code end |
#datacenter ⇒ Object (readonly)
Returns the value of attribute datacenter.
6 7 8 |
# File 'lib/notifu/model/event.rb', line 6 def datacenter @datacenter end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
23 24 25 |
# File 'lib/notifu/model/event.rb', line 23 def duration @duration end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/notifu/model/event.rb', line 7 def host @host end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
12 13 14 |
# File 'lib/notifu/model/event.rb', line 12 def interval @interval end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
20 21 22 |
# File 'lib/notifu/model/event.rb', line 20 def @message end |
#notifu_id ⇒ Object (readonly)
Returns the value of attribute notifu_id.
5 6 7 |
# File 'lib/notifu/model/event.rb', line 5 def notifu_id @notifu_id end |
#occurrences_count ⇒ Object (readonly)
Returns the value of attribute occurrences_count.
11 12 13 |
# File 'lib/notifu/model/event.rb', line 11 def occurrences_count @occurrences_count end |
#occurrences_trigger ⇒ Object (readonly)
Returns the value of attribute occurrences_trigger.
10 11 12 |
# File 'lib/notifu/model/event.rb', line 10 def occurrences_trigger @occurrences_trigger end |
#playbook ⇒ Object (readonly)
Returns the value of attribute playbook.
21 22 23 |
# File 'lib/notifu/model/event.rb', line 21 def playbook @playbook end |
#process_result ⇒ Object
Returns the value of attribute process_result.
26 27 28 |
# File 'lib/notifu/model/event.rb', line 26 def process_result @process_result end |
#refresh ⇒ Object (readonly)
Returns the value of attribute refresh.
25 26 27 |
# File 'lib/notifu/model/event.rb', line 25 def refresh @refresh end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
9 10 11 |
# File 'lib/notifu/model/event.rb', line 9 def service @service end |
#sgs ⇒ Object (readonly)
Returns the value of attribute sgs.
16 17 18 |
# File 'lib/notifu/model/event.rb', line 16 def sgs @sgs end |
#time_created ⇒ Object (readonly)
Returns the value of attribute time_created.
15 16 17 |
# File 'lib/notifu/model/event.rb', line 15 def time_created @time_created end |
#time_last_event ⇒ Object (readonly)
Returns the value of attribute time_last_event.
13 14 15 |
# File 'lib/notifu/model/event.rb', line 13 def time_last_event @time_last_event end |
#time_last_notified ⇒ Object (readonly)
Returns the value of attribute time_last_notified.
14 15 16 |
# File 'lib/notifu/model/event.rb', line 14 def time_last_notified @time_last_notified end |
#unsilence ⇒ Object (readonly)
Returns the value of attribute unsilence.
24 25 26 |
# File 'lib/notifu/model/event.rb', line 24 def unsilence @unsilence end |
Instance Method Details
#data ⇒ Object
43 44 45 |
# File 'lib/notifu/model/event.rb', line 43 def data @data ||= Hash[ instance_variables.map { |var| [var.to_s.sub(/^@/,""), instance_variable_get(var)] } ] end |
#group_sla ⇒ Object
39 40 41 |
# File 'lib/notifu/model/event.rb', line 39 def group_sla self.sgs.map { |gs| Hash[:group, gs.split(':')[0], :sla, gs.split(':')[1]] } end |
#update_process_result!(obj) ⇒ Object
47 48 49 50 |
# File 'lib/notifu/model/event.rb', line 47 def update_process_result!(obj) self.process_result ||= JSON.generate(Array.new) self.process_result = JSON.generate(JSON.parse(self.process_result) + [ obj ]) end |