Class: Hanami::Router::Inspector Private
- Inherits:
-
Object
- Object
- Hanami::Router::Inspector
- Defined in:
- lib/hanami/router/inspector.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Builds a representation of an array of routes according to a given formatter.
Instance Method Summary collapse
-
#add_route(route) ⇒ Object
Adds a route to be inspected.
-
#call ⇒ Any
Calls the formatter for all added routes.
-
#initialize(routes: [], formatter: Formatter::HumanFriendly.new) ⇒ Inspector
constructor
A new instance of Inspector.
Constructor Details
#initialize(routes: [], formatter: Formatter::HumanFriendly.new) ⇒ Inspector
Returns a new instance of Inspector.
20 21 22 23 |
# File 'lib/hanami/router/inspector.rb', line 20 def initialize(routes: [], formatter: Formatter::HumanFriendly.new) @routes = routes @formatter = formatter end |
Instance Method Details
#add_route(route) ⇒ Object
Adds a route to be inspected.
31 32 33 |
# File 'lib/hanami/router/inspector.rb', line 31 def add_route(route) @routes.push(route) end |
#call ⇒ Any
Calls the formatter for all added routes.
41 42 43 |
# File 'lib/hanami/router/inspector.rb', line 41 def call(...) @formatter.call(@routes, ...) end |