Class: Rails::Brochure::RouteReloader
- Inherits:
-
Object
- Object
- Rails::Brochure::RouteReloader
- Defined in:
- lib/rails-brochure/route_reloader.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RouteReloader
constructor
A new instance of RouteReloader.
- #last_route_change ⇒ Object
- #new_content? ⇒ Boolean
- #reload_routes ⇒ Object
Constructor Details
#initialize(app) ⇒ RouteReloader
Returns a new instance of RouteReloader.
4 5 6 |
# File 'lib/rails-brochure/route_reloader.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 |
# File 'lib/rails-brochure/route_reloader.rb', line 7 def call(env) reload_routes if new_content? @app.call(env) end |
#last_route_change ⇒ Object
20 21 22 |
# File 'lib/rails-brochure/route_reloader.rb', line 20 def last_route_change File.mtime("config/routes.rb") end |
#new_content? ⇒ Boolean
17 18 19 |
# File 'lib/rails-brochure/route_reloader.rb', line 17 def new_content? HomeContent.newest > last_route_change end |
#reload_routes ⇒ Object
11 12 13 14 15 16 |
# File 'lib/rails-brochure/route_reloader.rb', line 11 def reload_routes # we must touch the routes file in order for it to be reloaded FileUtils.touch("config/routes.rb") Rails.application.reload_routes! Rails.logger.info "ROUTES RELOADED by rails-brochure" end |