Sha256: 0c4c4c7803f59b3758de804eac52f9b01e00b8c865fad8c73ab2b0fa92fab66d

Contents?: true

Size: 631 Bytes

Versions: 7

Compression:

Stored size: 631 Bytes

Contents

module Rails
  module Brochure
    class RouteReloader
      def initialize(app)
        @app = app
      end
      def call(env)
        reload_routes if new_content?
        @app.call(env)
      end
      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
      def new_content?
        HomeContent.newest > last_route_change
      end
      def last_route_change
        File.mtime("config/routes.rb")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails-brochure-0.1.1 lib/rails-brochure/route_reloader.rb
rails-brochure-0.1.0 lib/rails-brochure/route_reloader.rb
rails-brochure-0.0.8 lib/rails-brochure/route_reloader.rb
rails-brochure-0.0.6 lib/rails-brochure/route_reloader.rb
rails-brochure-0.0.5 lib/rails-brochure/route_reloader.rb
rails-brochure-0.0.4 lib/rails-brochure/route_reloader.rb
rails-brochure-0.0.2 lib/rails-brochure/route_reloader.rb