Class: ExceptionNotifier::IrcNotifier

Inherits:
BaseNotifier show all
Defined in:
lib/exception_notifier/irc_notifier.rb

Instance Attribute Summary

Attributes inherited from BaseNotifier

#base_options

Instance Method Summary collapse

Methods inherited from BaseNotifier

#_post_callback, #_pre_callback, #send_notice

Constructor Details

#initialize(options) ⇒ IrcNotifier

Returns a new instance of IrcNotifier.



3
4
5
6
7
# File 'lib/exception_notifier/irc_notifier.rb', line 3

def initialize(options)
  super
  @config = OpenStruct.new
  parse_options(options)
end

Instance Method Details

#call(exception, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/exception_notifier/irc_notifier.rb', line 9

def call(exception, options={})
  message = "'#{exception.message}'"
  message += " on '#{exception.backtrace.first}'" if exception.backtrace
  if active?
    send_notice(exception, options, message) do |msg, _|
      send_message([*@config.prefix, *msg].join(' '))
    end
  end
end

#send_message(message) ⇒ Object



19
20
21
# File 'lib/exception_notifier/irc_notifier.rb', line 19

def send_message(message)
  CarrierPigeon.send @config.irc.merge({message: message})
end