Class: ExceptionNotifier::IrcNotifier

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ IrcNotifier

Returns a new instance of IrcNotifier.



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

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

Instance Method Details

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



8
9
10
11
12
# File 'lib/exception_notifier/irc_notifier.rb', line 8

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

#send_message(message) ⇒ Object



14
15
16
# File 'lib/exception_notifier/irc_notifier.rb', line 14

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