Class: Neo4j::Rails::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/rails/rack_middleware.rb

Overview

close lucene connections reset the Neo4j.threadlocal_ref_node (Multitenancy) clear the identity map

Defined Under Namespace

Classes: Body

Instance Method Summary (collapse)

Constructor Details

- (Middleware) initialize(app)

A new instance of Middleware



25
26
27
# File 'lib/neo4j/rails/rack_middleware.rb', line 25

def initialize(app)
  @app = app
end

Instance Method Details

- (Object) call(env)



29
30
31
32
33
34
35
36
37
38
# File 'lib/neo4j/rails/rack_middleware.rb', line 29

def call(env)
  enabled = IdentityMap.enabled
  IdentityMap.enabled = Neo4j::Config[:identity_map]
  status, headers, body = @app.call(env)
  [status, headers, Body.new(body, enabled)]
ensure
  IdentityMap.clear
  Neo4j::Rails::Model.close_lucene_connections
  Neo4j.threadlocal_ref_node = Neo4j.default_ref_node
end