Sha256: 38bc4c53428dfed72e9c85d1bb2156ecb661d69ce292957ad8bed18f45846235

Contents?: true

Size: 708 Bytes

Versions: 4

Compression:

Stored size: 708 Bytes

Contents

module CopycopterClient
  # Rack middleware that synchronizes with Copycopter during each request.
  #
  # This is injected into the Rails middleware stack in development environments.
  class RequestSync
    # @param app [Rack] the upstream app into whose responses to inject the editor
    # @param options [Hash]
    # @option options [Cache] :cache agent that should be flushed after each request
    def initialize(app, options)
      @app  = app
      @cache = options[:cache]
    end

    # Invokes the upstream Rack application and flushes the cache after each
    # request.
    def call(env)
      @cache.download
      response = @app.call(env)
      @cache.flush
      response
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
copycopter_client-1.1.1 lib/copycopter_client/request_sync.rb
copycopter_client-1.1.0 lib/copycopter_client/request_sync.rb
copycopter_client-1.0.4 lib/copycopter_client/request_sync.rb
copycopter_client-1.0.3 lib/copycopter_client/request_sync.rb