Sha256: a3c7156c5fd5652aa120c4ede3707fb6a826036b9e1cffc21dd7de34235256ed
Contents?: true
Size: 685 Bytes
Versions: 15
Compression:
Stored size: 685 Bytes
Contents
require "scorpion/rack/env" module Scorpion module Rack class Middleware ENV_KEY = 'scorpion.rack.instance'.freeze def initialize( app, nest = nil ) @app = app @nest = nest || Scorpion.instance.build_nest end def call( env ) env[ENV_KEY] = prepare_scorpion( nest.conceive, env ) @app.call(env).tap do free_scorpion( env ) end end private attr_reader :nest def prepare_scorpion( scorpion, env ) scorpion.hunt_for Rack::Env, return: env scorpion end def free_scorpion( env ) env[ENV_KEY].destroy end end end end
Version data entries
15 entries across 15 versions & 1 rubygems