Sha256: 52885e8173d786bbf813c0df149f653573fddc6f88d2b180c525815344d7a9cc
Contents?: true
Size: 1.04 KB
Versions: 6
Compression:
Stored size: 1.04 KB
Contents
module MarkMapper module Middleware # Usage: # # config.middleware.insert_after \ # ActionDispatch::Callbacks, # MarkMapper::Middleware::IdentityMap # # You have to insert after callbacks so the entire request is wrapped. class IdentityMap class Body extend Forwardable def_delegator :@target, :each def initialize(target, original) @target = target @original = original end def close @target.close if @target.respond_to?(:close) ensure MarkMapper::Plugins::IdentityMap.enabled = @original MarkMapper::Plugins::IdentityMap.clear end end def initialize(app) @app = app end def call(env) MarkMapper::Plugins::IdentityMap.clear enabled = MarkMapper::Plugins::IdentityMap.enabled MarkMapper::Plugins::IdentityMap.enabled = true status, headers, body = @app.call(env) [status, headers, Body.new(body, enabled)] end end end end
Version data entries
6 entries across 6 versions & 1 rubygems