Class: ActiveSupport::Cache::Strategy::LocalCache::Middleware
- Defined in:
- lib/active_support/cache/strategy/local_cache.rb
Overview
– This class wraps up local storage for middlewares. Only the middleware method should construct them.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
:nodoc:.
-
#thread_local_key ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(name, thread_local_key) ⇒ Middleware
constructor
A new instance of Middleware.
- #new(app) ⇒ Object
Constructor Details
#initialize(name, thread_local_key) ⇒ Middleware
Returns a new instance of Middleware.
59 60 61 62 63 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 59 def initialize(name, thread_local_key) @name = name @thread_local_key = thread_local_key @app = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
:nodoc:
57 58 59 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 57 def name @name end |
#thread_local_key ⇒ Object (readonly)
:nodoc:
57 58 59 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 57 def thread_local_key @thread_local_key end |
Instance Method Details
#call(env) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 70 def call(env) Thread.current[thread_local_key] = LocalStore.new @app.call(env) ensure Thread.current[thread_local_key] = nil end |
#new(app) ⇒ Object
65 66 67 68 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 65 def new(app) @app = app self end |