class ExceptionNotifier::HipchatNotifier
Attributes
from[RW]
message_options[RW]
room[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/exception_notifier/hipchat_notifier.rb, line 8 def initialize(options) begin api_token = options.delete(:api_token) room_name = options.delete(:room_name) @from = options.delete(:from) || 'Exception' @room = HipChat::Client.new(api_token)[room_name] @message_options = options @message_options[:color] ||= 'red' rescue @room = nil end end
Public Instance Methods
call(exception, options={})
click to toggle source
# File lib/exception_notifier/hipchat_notifier.rb, line 21 def call(exception, options={}) return if !active? message = "A new exception occurred: '#{exception.message}' on '#{exception.backtrace.first}'" @room.send(@from, message, @message_options) end
Private Instance Methods
active?()
click to toggle source
# File lib/exception_notifier/hipchat_notifier.rb, line 30 def active? !@room.nil? end