Class: Hanami::Slice::Routing::Resolver Private
- Inherits:
-
Object
- Object
- Hanami::Slice::Routing::Resolver
- Defined in:
- lib/hanami/slice/routing/resolver.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.
Hanami app router endpoint resolver
This resolves endpoints objects from a slice container using the strings passed to ‘to:` as their container keys.
Constant Summary collapse
- SLICE_ACTIONS_KEY_NAMESPACE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"actions"
Instance Method Summary collapse
- #call(_path, endpoint) ⇒ Object private
- #find_slice(slice_name) ⇒ Object private
-
#initialize(slice:) ⇒ Resolver
constructor
private
A new instance of Resolver.
- #to_slice(slice_name) ⇒ Object private
Constructor Details
#initialize(slice:) ⇒ Resolver
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.
Returns a new instance of Resolver.
21 22 23 |
# File 'lib/hanami/slice/routing/resolver.rb', line 21 def initialize(slice:) @slice = slice end |
Instance Method Details
#call(_path, endpoint) ⇒ 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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/hanami/slice/routing/resolver.rb', line 39 def call(_path, endpoint) endpoint = case endpoint when String resolve_slice_action(endpoint) when Class endpoint.respond_to?(:call) ? endpoint : endpoint.new else endpoint end unless endpoint.respond_to?(:call) raise Routes::NotCallableEndpointError.new(endpoint) end endpoint end |
#find_slice(slice_name) ⇒ 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.
27 28 29 |
# File 'lib/hanami/slice/routing/resolver.rb', line 27 def find_slice(slice_name) slice.slices[slice_name] end |
#to_slice(slice_name) ⇒ 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.
33 34 35 |
# File 'lib/hanami/slice/routing/resolver.rb', line 33 def to_slice(slice_name) self.class.new(slice: find_slice(slice_name)) end |