Class: Timber::Integrations::Rack::UserContext
- Inherits:
-
Object
- Object
- Timber::Integrations::Rack::UserContext
- Defined in:
- lib/timber/integrations/rack/user_context.rb
Overview
Reponsible for adding the user context.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ UserContext
constructor
A new instance of UserContext.
Constructor Details
#initialize(app) ⇒ UserContext
Returns a new instance of 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 21 22 23 24 |
# File 'lib/timber/integrations/rack/user_context.rb', line 10 def call(env) user = get_user(env) if user context = Contexts::User.new( id: user_id(user), name: user_name(user), email: user_email(user) ) CurrentContext.with(context) do @app.call(env) end else @app.call(env) end end |