Class: ActiveSupport::Cache::Strategy::LocalCache::Middleware
- Defined in:
- activesupport/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
Returns the value of attribute name.
-
#thread_local_key ⇒ Object
readonly
Returns the value of attribute thread_local_key.
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 'activesupport/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)
Returns the value of attribute name
57 58 59 |
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 57 def name @name end |
#thread_local_key ⇒ Object (readonly)
Returns the value of attribute thread_local_key
57 58 59 |
# File 'activesupport/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 'activesupport/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 |