Class: Checken::ReloadMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/checken/reload_middleware.rb

Constant Summary collapse

MUTEX =
Mutex.new

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ReloadMiddleware

Returns a new instance of ReloadMiddleware.



8
9
10
# File 'lib/checken/reload_middleware.rb', line 8

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/checken/reload_middleware.rb', line 12

def call(env)
  # If we need to reload, we shall do that here.
  unless Rails.application.config.cache_classes
    MUTEX.synchronize do
      Checken::Schema.instance.reload
    end
  end

  # Call our app as normal
  @app.call(env)
end