Class: Raygun::Middleware::RailsInsertAffectedUser

Inherits:
Object
  • Object
show all
Defined in:
lib/raygun/middleware/rails_insert_affected_user.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RailsInsertAffectedUser

Returns a new instance of RailsInsertAffectedUser.



6
7
8
# File 'lib/raygun/middleware/rails_insert_affected_user.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/raygun/middleware/rails_insert_affected_user.rb', line 10

def call(env)
  response = @app.call(env)
rescue Exception => exception
  if (controller = env["action_controller.instance"]) && controller.respond_to?(Raygun.configuration.affected_user_method)
    user = controller.send(Raygun.configuration.affected_user_method)

    if user
      identifier = if (m = Raygun.configuration.affected_user_identifier_methods.detect { |m| user.respond_to?(m) })
        user.send(m)
      else
        user
      end

      env["raygun.affected_user"] = { :identifier => identifier }
    end
    
  end
  raise exception
end