Class: Notificate::Rails::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/notificate-rails/rack.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Rack

Returns a new instance of Rack.



3
4
5
# File 'lib/notificate-rails/rack.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/notificate-rails/rack.rb', line 7

def call(env)
  @env = env

  begin
    result = @app.call(env)
  rescue ::Exception => ex
    @env['notificate.notified'] = ::Notificate::ExceptionCatcher.notify(ex, rack_data)

    raise ex
  end

  result
end

#rack_dataObject



21
22
23
24
25
26
# File 'lib/notificate-rails/rack.rb', line 21

def rack_data
  {
    environment: ::Notificate::Rails.options.environment,
    root:        ::Notificate::Rails.options.project_root
  }
end