Sha256: 6e8c896eebe04bfc6f5d2b3ff120d2cb0bc4117fc6c7b5bb7ff459b3866d96e7

Contents?: true

Size: 911 Bytes

Versions: 9

Compression:

Stored size: 911 Bytes

Contents

# encoding: utf-8
module Rack
  module Mongoid
    module Middleware

      # This middleware contains the behaviour needed to properly use the
      # identity map in Rack based applications.
      class IdentityMap

        # Initialize the new middleware.
        #
        # @example Init the middleware.
        # IdentityMap.new(app)
        #
        # @param [ Object ] app The application.
        #
        # @since 2.1.0
        def initialize(app)
          @app = app
        end

        # Make the request with the provided environment.
        #
        # @example Make the request.
        # identity_map.call(env)
        #
        # @param [ Object ] env The environment.
        #
        # @return [ Array ] The status, headers, and response.
        #
        # @since 2.1.0
        def call(env)
          ::Mongoid.unit_of_work { @app.call(env) }
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mongoid-3.0.9 lib/rack/mongoid/middleware/identity_map.rb
mongoid-3.0.6 lib/rack/mongoid/middleware/identity_map.rb
mongoid-3.0.5 lib/rack/mongoid/middleware/identity_map.rb
mongoid-3.0.4 lib/rack/mongoid/middleware/identity_map.rb
mongoid-3.0.3 lib/rack/mongoid/middleware/identity_map.rb
mongoid-3.0.2 lib/rack/mongoid/middleware/identity_map.rb
mongoid-3.0.1 lib/rack/mongoid/middleware/identity_map.rb
mongoid-3.0.0 lib/rack/mongoid/middleware/identity_map.rb
mongoid-3.0.0.rc lib/rack/mongoid/middleware/identity_map.rb