Class: Bullhorn

Inherits:
Object
  • Object
show all
Includes:
Sender
Defined in:
lib/bullhorn.rb,
lib/bullhorn/plugin.rb,
lib/bullhorn/sender.rb

Defined Under Namespace

Modules: Plugin, Sender

Constant Summary collapse

VERSION =
"0.0.5"
URL =
"http://www.bullhorn.it/api/v1/exception"
FILTERING =
%(['"]?\[?%s\]?['"]?=>?([^&\s]*))

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sender

#notify, #serialize

Constructor Details

#initialize(app, options = {}) ⇒ Bullhorn

Returns a new instance of Bullhorn.



25
26
27
28
29
30
31
# File 'lib/bullhorn.rb', line 25

def initialize(app, options = {})
  @app               = app
  @api_key           = options[:api_key] || raise(ArgumentError, ":api_key is required")
  @filters           = Array(options[:filters])
  @url               = options[:url] || URL
  @ignore_exceptions = Array(options[:ignore_exceptions] || default_ignore_exceptions)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#filtersObject (readonly)

Returns the value of attribute filters.



18
19
20
# File 'lib/bullhorn.rb', line 18

def filters
  @filters
end

#ignore_exceptionsObject (readonly)

Returns the value of attribute ignore_exceptions.



21
22
23
# File 'lib/bullhorn.rb', line 21

def ignore_exceptions
  @ignore_exceptions
end

#urlObject (readonly)

Returns the value of attribute url.



20
21
22
# File 'lib/bullhorn.rb', line 20

def url
  @url
end

Instance Method Details

#call(env) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bullhorn.rb', line 33

def call(env)
  status, headers, body =
    begin
      @app.call(env)
    rescue Exception => ex
      unless ignore_exceptions.include?(ex.class)
        notify ex, env
      end

      raise ex
    end

  [status, headers, body]
end