Class: Rack::Mongoid::Middleware::IdentityMap

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/mongoid/middleware/identity_map.rb

Overview

This middleware contains the behaviour needed to properly use the identity map in Rack based applications. This middleware will properly handle Rails or Rack streaming responses.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ IdentityMap

Initialize the new middleware.

Examples:

Init the middleware.

IdentityMap.new(app)

Parameters:

  • app (Object)

    The application.

Since:

  • 2.1.0



19
20
21
# File 'lib/rack/mongoid/middleware/identity_map.rb', line 19

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Array

Make the request with the provided environment.

Examples:

Make the request.

identity_map.call(env)

Parameters:

  • env (Object)

    The environment.

Returns:

  • (Array)

    The status, headers, and response.

Since:

  • 2.1.0



33
34
35
# File 'lib/rack/mongoid/middleware/identity_map.rb', line 33

def call(env)
  ::Mongoid.unit_of_work { @app.call(env) }
end