Class: Hanami::Routing::LazyEndpoint Private
- Defined in:
- lib/hanami/routing/endpoint.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.
Routing endpoint This is the object that responds to an HTTP request made against a certain path.
The router will use this class for the same use cases of ‘ClassEndpoint`, but when the target class can’t be found, instead of raise a ‘LoadError` we reference in a lazy endpoint.
For each incoming HTTP request, it will look for the referenced class, then it will instantiate and invoke #call on the object.
This behavior is required to solve a chicken-egg situation when we try to load the router first and then the application with all its endpoints.
Instance Method Summary collapse
-
#call(env) ⇒ Object
private
Rack interface.
-
#initialize(name, namespace) ⇒ LazyEndpoint
constructor
private
Initialize the lazy endpoint.
- #inspect ⇒ Object private
Methods inherited from Endpoint
#destination_path, #redirect?, #routable?
Constructor Details
#initialize(name, namespace) ⇒ LazyEndpoint
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 the lazy endpoint
129 130 131 |
# File 'lib/hanami/routing/endpoint.rb', line 129 def initialize(name, namespace) @name, @namespace = name, namespace end |
Instance Method Details
#call(env) ⇒ 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.
Rack interface
139 140 141 |
# File 'lib/hanami/routing/endpoint.rb', line 139 def call(env) obj.call(env) end |
#inspect ⇒ 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.
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/hanami/routing/endpoint.rb', line 145 def inspect # TODO review this implementation once the namespace feature will be # cleaned up. result = klass rescue nil if result.nil? result = @name result = "#{ @namespace }::#{ result }" if @namespace != Object end result end |