Class: RouteDog::Middleware::Watcher

Inherits:
RouteDog
  • Object
show all
Defined in:
lib/route_dog/middleware/watcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RouteDog

action_string_for_route, config_file, constantize_controller_str, delete_watched_routes_file, load_watched_routes, route_tested?, route_tested_with_requirements?, watched_routes_file, write_watched_routes

Constructor Details

#initialize(app) ⇒ Watcher

Returns a new instance of Watcher.



7
8
9
10
# File 'lib/route_dog/middleware/watcher.rb', line 7

def initialize(app)
  @app = app
  @watched_routes = ::RouteDog.load_watched_routes
end

Instance Attribute Details

#watched_routesObject

Returns the value of attribute watched_routes.



5
6
7
# File 'lib/route_dog/middleware/watcher.rb', line 5

def watched_routes
  @watched_routes
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/route_dog/middleware/watcher.rb', line 12

def call(env)
  @env = env

  status, headers, response = @app.call(env)

  store_route if status.to_i < 400

  [status, headers, response]
end