Class: ExceptionNotifier::HipchatNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- 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.
Attributes inherited from BaseNotifier
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ HipchatNotifier
constructor
A new instance of HipchatNotifier.
Methods inherited from BaseNotifier
#_post_callback, #_pre_callback, #send_notice
Constructor Details
#initialize(options) ⇒ HipchatNotifier
Returns a new instance of HipchatNotifier.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/exception_notifier/hipchat_notifier.rb', line 8 def initialize() super begin api_token = .delete(:api_token) room_name = .delete(:room_name) opts = { :api_version => .delete(:api_version) || 'v1' } @from = .delete(:from) || 'Exception' @room = HipChat::Client.new(api_token, opts)[room_name] @message_template = .delete(:message_template) || ->(exception) { msg = "A new exception occurred: '#{Rack::Utils.escape_html(exception.)}'" msg += " on '#{exception.backtrace.first}'" if exception.backtrace msg } @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
30 31 32 33 34 35 36 37 |
# File 'lib/exception_notifier/hipchat_notifier.rb', line 30 def call(exception, ={}) return if !active? = @message_template.call(exception) send_notice(exception, , , @message_options) do |msg, | @room.send(@from, msg, ) end end |