class ExceptionNotifier::WebhookNotifier

Public Class Methods

new(options) click to toggle source
# File lib/exception_notifier/webhook_notifier.rb, line 4
def initialize(options)
  @default_options = options
end

Public Instance Methods

call(exception, options={}) click to toggle source
# File lib/exception_notifier/webhook_notifier.rb, line 8
def call(exception, options={})
  options = options.reverse_merge(@default_options)
  url = options.delete(:url)
  http_method = options.delete(:http_method) || :post

  options[:body] ||= {}
  options[:body][:exception] = {:error_class => exception.class.to_s,
                                :message => exception.message.inspect,
                                :backtrace => exception.backtrace}

  HTTParty.send(http_method, url, options)
end