Class: RoutesLazyRoutes::LazyRoutesMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/routes_lazy_routes/lazy_routes_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ LazyRoutesMiddleware

Returns a new instance of LazyRoutesMiddleware.



5
6
7
8
# File 'lib/routes_lazy_routes/lazy_routes_middleware.rb', line 5

def initialize(app)
  @app = app
  @loaded = false
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/routes_lazy_routes/lazy_routes_middleware.rb', line 10

def call(env)
  unless @loaded
    RoutesLazyRoutes.eager_load!
    @loaded = true
  end

  @app.call env
end