Class: Releaf::Content::RoutesReloader
- Inherits:
-
Object
- Object
- Releaf::Content::RoutesReloader
- Defined in:
- app/middleware/releaf/content/routes_reloader.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RoutesReloader
constructor
A new instance of RoutesReloader.
Constructor Details
#initialize(app) ⇒ RoutesReloader
Returns a new instance of RoutesReloader.
3 4 5 6 |
# File 'app/middleware/releaf/content/routes_reloader.rb', line 3 def initialize(app) @app = app self.class.routes_loaded end |
Class Method Details
.reload_if_expired ⇒ Object
17 18 19 20 21 22 |
# File 'app/middleware/releaf/content/routes_reloader.rb', line 17 def self.reload_if_expired # TODO Node class should be configurable return unless ::Node.updated_at.present? && @updated_at && @updated_at < ::Node.updated_at Rails.application.reload_routes! routes_loaded end |
.routes_loaded ⇒ Object
13 14 15 |
# File 'app/middleware/releaf/content/routes_reloader.rb', line 13 def self.routes_loaded @updated_at = Time.now end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 |
# File 'app/middleware/releaf/content/routes_reloader.rb', line 8 def call(env) self.class.reload_if_expired @app.call(env) end |