Class: ExceptionNotifier::IdobataNotifier

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ IdobataNotifier

Returns a new instance of IdobataNotifier.

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/exception_notifier/idobata_notifier.rb', line 9

def initialize(options)
  @options = extract_global_options(options, :url, :skip_library_backtrace, :proxy)

  raise(ArgumentError, 'Endpoint must be specified') unless @url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/exception_notifier/idobata_notifier.rb', line 7

def url
  @url
end

Instance Method Details

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



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/exception_notifier/idobata_notifier.rb', line 15

def call(exception, options={})
  enviroments =
    if options[:env]
      request_option(ActionDispatch::Request.new(options[:env]))
    else
      # [TODO] - Add option specification route for non-web notification
      {'Timestamp' => Time.zone.now}
    end

  source = build_message(exception, enviroments)

  http_client.post_form URI.parse(url),  source: source, format: :html
end