Class: Yeller::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/yeller/rack.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Rack

Returns a new instance of Rack.



25
26
27
# File 'lib/yeller/rack.rb', line 25

def initialize(app)
  @app = app
end

Class Method Details

.clientObject



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

def self.client
  @client
end

.configure(&block) ⇒ Object



6
7
8
9
10
# File 'lib/yeller/rack.rb', line 6

def self.configure(&block)
  @config_blocks ||= []
  @config_blocks << block
  @client = Yeller.client(*@config_blocks)
end

.enabled?Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/yeller/rack.rb', line 16

def self.enabled?
  return false unless @client
  @client.enabled?
end

.report(exception, options = {}) ⇒ Object



12
13
14
# File 'lib/yeller/rack.rb', line 12

def self.report(exception, options={})
  @client.report(exception, options)
end

.rescue_rack_exception(exception, env) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/yeller/rack.rb', line 38

def self.rescue_rack_exception(exception, env)
  request = ::Rack::Request.new(env)
  Yeller::Rack.report(
    exception,
    :url => request.url,
    :custom_data => {
      :params => request.params,
      :session => env.fetch('rack.session', {}),
  })
end

Instance Method Details

#call(env) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/yeller/rack.rb', line 29

def call(env)
  begin
    @app.call(env)
  rescue Exception => exception
    Yeller::Rack.rescue_rack_exception(exception, env)
    raise exception
  end
end