Sha256: 6d001483567cb8dd8888a182a3cf8db1adc5398da645782914a77af0b8754023

Contents?: true

Size: 473 Bytes

Versions: 1

Compression:

Stored size: 473 Bytes

Contents

require 'rack/body_proxy'

module Flipper
  module Middleware
    class Memoizer
      def initialize(app, flipper)
        @app = app
        @flipper = flipper
      end

      def call(env)
        original = @flipper.adapter.memoizing?
        @flipper.adapter.memoize = true

        response = @app.call(env)
        response[2] = Rack::BodyProxy.new(response[2]) {
          @flipper.adapter.memoize = original
        }
        response
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flipper-0.5.0 lib/flipper/middleware/memoizer.rb