Class: Notifu::Model::Issue

Inherits:
Ohm::Model
  • Object
show all
Includes:
Util
Defined in:
lib/notifu/model/issue.rb

Instance Method Summary collapse

Methods included from Util

action_log, log, option

Instance Method Details

#create_from_event(event) ⇒ Object


46
47
48
49
# File 'lib/notifu/model/issue.rb', line 46

def create_from_event event
  event.each { |name, value| instance_variable_set(name, value) }
  self.save
end

#time_last_notified!(group_name, sla_name, time) ⇒ Object


41
42
43
44
# File 'lib/notifu/model/issue.rb', line 41

def time_last_notified! (group_name, sla_name, time)
  obj = JSON.parse(self.time_last_notified)
  self.time_last_notified = JSON.generate(obj.merge({ "#{group_name}:#{sla_name}" => time }))
end

#time_last_notified?(group_name, sla_name) ⇒ Boolean

Returns:

  • (Boolean)

33
34
35
36
37
38
39
# File 'lib/notifu/model/issue.rb', line 33

def time_last_notified? (group_name, sla_name)
  begin
    JSON.parse(self.time_last_notified)["#{group_name}:#{sla_name}"]
  rescue
    0
  end
end