Class: Hanami::Routes
- Inherits:
-
Object
- Object
- Hanami::Routes
- Defined in:
- lib/hanami/routes.rb
Overview
App routes
Users are expected to inherit from this class to define their app routes.
Defined Under Namespace
Classes: MissingActionError, NotCallableEndpointError, RoutesProc
Class Method Summary collapse
- .build_routes(definitions = self.definitions) ⇒ Object private
- .definitions ⇒ Object private
- .routes ⇒ Object private
Class Method Details
.build_routes(definitions = self.definitions) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/hanami/routes.rb', line 100 def build_routes(definitions = self.definitions) return RoutesProc.empty if definitions.empty? routes_proc = proc do definitions.each do |(name, args, kwargs, block)| if block public_send(name, *args, **kwargs, &block) else public_send(name, *args, **kwargs) end end end RoutesProc.new(routes_proc) end |
.definitions ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
117 118 119 |
# File 'lib/hanami/routes.rb', line 117 def definitions @definitions ||= [] end |
.routes ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
94 95 96 |
# File 'lib/hanami/routes.rb', line 94 def self.routes @routes ||= build_routes end |