Class: God::Contacts::Airbrake

Inherits:
God::Contact show all
Defined in:
lib/god/contacts/airbrake.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from God::Contact

#group, #info, #name

Instance Method Summary collapse

Methods inherited from God::Contact

#arg, defaults, #friendly_name, generate, normalize, valid?

Methods included from God::Configurable

#base_name, complain, #complain, #friendly_name, #prepare, #reset

Class Attribute Details

.apikeyObject

Returns the value of attribute apikey.



15
16
17
# File 'lib/god/contacts/airbrake.rb', line 15

def apikey
  @apikey
end

Instance Attribute Details

#apikeyObject

Returns the value of attribute apikey.



24
25
26
# File 'lib/god/contacts/airbrake.rb', line 24

def apikey
  @apikey
end

Instance Method Details

#notify(message, time, priority, category, host) ⇒ Object



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

def notify(message, time, priority, category, host)
  ::Airbrake.configure {}

  message = "God: #{message.to_s} at #{host}"
  message << " | #{[category, priority].join(" ")}" unless category.to_s.empty? or priority.to_s.empty?

  if ::Airbrake.notify nil, :error_message => message, :api_key => arg(:apikey)
    self.info = "sent airbrake notification to #{self.name}"
  else
    self.info = "failed to send airbrake notification to #{self.name}"
  end
rescue Object => e
  applog(nil, :info, "failed to send airbrake notification: #{e.message}")
  applog(nil, :debug, e.backtrace.join("\n"))
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/god/contacts/airbrake.rb', line 18

def valid?
  valid = true
  valid &= complain("Attribute 'apikey' must be specified", self) if self.apikey.nil?
  valid
end