Class: ExceptionNotifier::HipchatNotifier
- Inherits:
-
Object
- Object
- ExceptionNotifier::HipchatNotifier
- Defined in:
- lib/exception_notifier/hipchat_notifier.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#message_options ⇒ Object
Returns the value of attribute message_options.
-
#room ⇒ Object
Returns the value of attribute room.
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ HipchatNotifier
constructor
A new instance of HipchatNotifier.
Constructor Details
#initialize(options) ⇒ HipchatNotifier
Returns a new instance of HipchatNotifier.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/exception_notifier/hipchat_notifier.rb', line 8 def initialize() begin api_token = .delete(:api_token) room_name = .delete(:room_name) @from = .delete(:from) || 'Exception' @room = HipChat::Client.new(api_token)[room_name] @message_options = @message_options[:color] ||= 'red' rescue @room = nil end end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
4 5 6 |
# File 'lib/exception_notifier/hipchat_notifier.rb', line 4 def from @from end |
#message_options ⇒ Object
Returns the value of attribute message_options.
6 7 8 |
# File 'lib/exception_notifier/hipchat_notifier.rb', line 6 def @message_options end |
#room ⇒ Object
Returns the value of attribute room.
5 6 7 |
# File 'lib/exception_notifier/hipchat_notifier.rb', line 5 def room @room end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/exception_notifier/hipchat_notifier.rb', line 21 def call(exception, ={}) return if !active? = "A new exception occurred: '#{exception.}' on '#{exception.backtrace.first}'" @room.send(@from, , @message_options) end |