Class: Timber::Integrations::Rack::UserContext

Inherits:
Object
  • Object
show all
Defined in:
lib/timber/integrations/rack/user_context.rb

Overview

Reponsible for adding the user context.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ UserContext



6
7
8
# File 'lib/timber/integrations/rack/user_context.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
# File 'lib/timber/integrations/rack/user_context.rb', line 10

def call(env)
  user_hash = get_user_hash(env)
  if user_hash
    context = Contexts::User.new(user_hash)
    CurrentContext.with(context) do
      @app.call(env)
    end
  else
    @app.call(env)
  end
end