Method: Hanami::Slice::ClassMethods#router
- Defined in:
- lib/hanami/slice.rb
#router(inspector: nil) ⇒ Hanami::Slice::Router?
Returns the slice’s router, if or nil if no routes are defined.
An optional inspector, implementing the Hanami::Router::Inspector interface, may be provided at first call (the router is then memoized for subsequent accesses). An inspector is used by the ‘hanami routes` CLI comment to provide a list of available routes.
The returned router is a Router, which provides all Hanami::Router functionality, with the addition of support for slice mounting with the Router#slice.
764 765 766 767 768 769 770 |
# File 'lib/hanami/slice.rb', line 764 def router(inspector: nil) raise SliceLoadError, "#{self} must be prepared before loading the router" unless prepared? @_mutex.synchronize do @_router ||= load_router(inspector: inspector) end end |