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
-
#local_cache_key ⇒ Object
readonly
Returns the value of attribute local_cache_key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(name, local_cache_key) ⇒ Middleware
constructor
A new instance of Middleware.
- #new(app) ⇒ Object
Constructor Details
#initialize(name, local_cache_key) ⇒ Middleware
Returns a new instance of Middleware.
70 71 72 73 74 |
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 70 def initialize(name, local_cache_key) @name = name @local_cache_key = local_cache_key @app = nil end |
Instance Attribute Details
#local_cache_key ⇒ Object (readonly)
Returns the value of attribute local_cache_key
68 69 70 |
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 68 def local_cache_key @local_cache_key end |
#name ⇒ Object (readonly)
Returns the value of attribute name
68 69 70 |
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 68 def name @name end |
Instance Method Details
#call(env) ⇒ Object
81 82 83 84 85 86 |
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 81 def call(env) LocalCacheRegistry.set_cache_for(local_cache_key, LocalStore.new) @app.call(env) ensure LocalCacheRegistry.set_cache_for(local_cache_key, nil) end |
#new(app) ⇒ Object
76 77 78 79 |
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 76 def new(app) @app = app self end |