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 |
# File 'lib/timber/integrations/rack/user_context.rb', line 10 def call(env) debug { "#{self.class.name} - Starting user context" } user_hash = get_user_hash(env) if user_hash debug { "#{self.class.name} - User hash found: #{user_hash.inspect}" } context = Contexts::User.new(user_hash) CurrentContext.with(context) do @app.call(env) end else debug { "#{self.class.name} - User hash not found" } @app.call(env) end end |