Sha256: 78bf5f0fba72cb49dd20dc97cb49a5217a4c1ee44f714f3c5dd3b6cb23593179

Contents?: true

Size: 938 Bytes

Versions: 188

Compression:

Stored size: 938 Bytes

Contents

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

      # 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

188 entries across 96 versions & 4 rubygems

Version Path
mongoid-2.1.7 lib/rack/mongoid/middleware/identity_map.rb
mongoid-2.1.6 lib/rack/mongoid/middleware/identity_map.rb
mongoid-2.1.5 lib/rack/mongoid/middleware/identity_map.rb
mongoid-2.1.4 lib/rack/mongoid/middleware/identity_map.rb
mongoid-2.1.3 lib/rack/mongoid/middleware/identity_map.rb
mongoid-2.1.2 lib/rack/mongoid/middleware/identity_map.rb
mongoid-2.1.1 lib/rack/mongoid/middleware/identity_map.rb
mongoid-2.1.0 lib/rack/mongoid/middleware/identity_map.rb