Class: CopycopterClient::RequestSync
- Inherits:
-
Object
- Object
- CopycopterClient::RequestSync
- Defined in:
- lib/copycopter_client/request_sync.rb
Overview
Rack middleware that synchronizes with Copycopter during each request.
This is injected into the Rails middleware stack in development environments.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Invokes the upstream Rack application and flushes the cache after each request.
-
#initialize(app, options) ⇒ RequestSync
constructor
A new instance of RequestSync.
Constructor Details
#initialize(app, options) ⇒ RequestSync
Returns a new instance of RequestSync.
9 10 11 12 |
# File 'lib/copycopter_client/request_sync.rb', line 9 def initialize(app, ) @app = app @cache = [:cache] end |
Instance Method Details
#call(env) ⇒ Object
Invokes the upstream Rack application and flushes the cache after each request.
16 17 18 19 20 21 |
# File 'lib/copycopter_client/request_sync.rb', line 16 def call(env) @cache.download unless asset_request?(env) response = @app.call(env) @cache.flush unless asset_request?(env) response end |