Class: Lotus::Routing::LazyEndpoint Private
- Defined in:
- lib/lotus/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
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
108 109 110 |
# File 'lib/lotus/routing/endpoint.rb', line 108 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
117 118 119 |
# File 'lib/lotus/routing/endpoint.rb', line 117 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.
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/lotus/routing/endpoint.rb', line 122 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 |