Class: Guacamole::IdentityMap::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/guacamole/identity_map.rb

Overview

The IdentityMap::Session acts as Rack middleware to reset the Guacamole::IdentityMap before each request.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Session

Create a new instance of the Session middleware

You must pass an object that responds to call in the constructor. This will be the called after the IdentityMap has been purged.

Parameters:

  • app (#call)

    Any object that responds to call



28
29
30
# File 'lib/guacamole/identity_map.rb', line 28

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Array

Run the concrete middleware

This satisfies the Rack interface and will be called to reset the IdentityMap before each request. In the end the @app will be called.

Parameters:

  • env (Hash)

    The environment of the Rack request

Returns:

  • (Array)

    a Rack compliant response array



39
40
41
42
43
44
# File 'lib/guacamole/identity_map.rb', line 39

def call(env)
  Guacamole.logger.debug '[SESSION] Resetting the IdentityMap'
  IdentityMap.reset

  @app.call(env)
end