class Flipflop::FeatureCache::Middleware

Public Class Methods

new(app) click to toggle source
# File lib/flipflop/feature_cache.rb, line 4
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/flipflop/feature_cache.rb, line 8
def call(env)
  return @app.call(env) if FeatureCache.current.enabled?

  FeatureCache.current.enable!
  response = @app.call(env)
  response[2] = Rack::BodyProxy.new(response[2]) do
    FeatureCache.current.disable!
  end
  response
rescue Exception => err
  FeatureCache.current.disable!
  raise err
end