Class: Hanami::Routing::EndpointResolver Private
- Inherits:
-
Object
- Object
- Hanami::Routing::EndpointResolver
- Defined in:
- lib/hanami/routing/endpoint_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.
Resolve duck-typed endpoints
Constant Summary collapse
- NAMING_PATTERN =
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.
'%{controller}::%{action}'.freeze
- DEFAULT_RESPONSE =
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.
[404, {'X-Cascade' => 'pass'}, 'Not Found'].freeze
- ACTION_SEPARATOR =
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.
Default separator for controller and action. A different separator can be passed to #initialize with the ‘:separator` option.
'#'.freeze
Instance Attribute Summary collapse
- #action_separator ⇒ Object readonly private
Instance Method Summary collapse
-
#find(options) ⇒ Object
private
Finds a path from the given options.
-
#initialize(options = {}) ⇒ Hanami::Routing::EndpointResolver
constructor
private
Initialize an endpoint resolver.
-
#resolve(options, &endpoint) ⇒ Endpoint
private
Resolve the given set of HTTP verb, path, endpoint and options.
Constructor Details
#initialize(options = {}) ⇒ Hanami::Routing::EndpointResolver
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.
Initialize an endpoint resolver
101 102 103 104 105 106 |
# File 'lib/hanami/routing/endpoint_resolver.rb', line 101 def initialize( = {}) @endpoint_class = [:endpoint] || Endpoint @namespace = [:namespace] || Object @action_separator = [:action_separator] || ACTION_SEPARATOR @pattern = [:pattern] || NAMING_PATTERN end |
Instance Attribute Details
#action_separator ⇒ Object (readonly)
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.
37 38 39 |
# File 'lib/hanami/routing/endpoint_resolver.rb', line 37 def action_separator @action_separator end |
Instance Method Details
#find(options) ⇒ 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.
Finds a path from the given options.
181 182 183 |
# File 'lib/hanami/routing/endpoint_resolver.rb', line 181 def find() [:to] end |
#resolve(options, &endpoint) ⇒ Endpoint
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.
Resolve the given set of HTTP verb, path, endpoint and options. If it fails to resolve, it will mount the default endpoint to the given path, which returns an 404 (Not Found).
166 167 168 169 |
# File 'lib/hanami/routing/endpoint_resolver.rb', line 166 def resolve(, &endpoint) result = endpoint || find() resolve_callable(result) || resolve_matchable(result) || default end |