class StubRequests::Endpoint
Class
Endpoint
provides registration of stubbed endpoints
@author Mikael Henriksson <mikael@zoolutions.se>
Attributes
route_params[R]
@!attribute [rw] route_params
@see @return [Array<Symbol>] an array with required route params
service_id[R]
@!attribute [rw] service_id
@see @return [Symbol] the id of the service
service_uri[R]
@!attribute [rw] service_uri
@see @return [String] a service's base URI
uri[R]
@!attribute [rw] uri
@return [String] the full uri for the endpoint
Public Class Methods
new(endpoint_id:, service_id:, service_uri:, verb:, path:)
click to toggle source
Initialize an endpoint for a specific {Service}
@param [Symbol] endpoint_id a descriptive id for the endpoint @param [Symbol] service_id
the id of a registered service @param [String] service_uri
the uri of a registered service @param [Symbol] verb a HTTP verb @param [String] path how to reach the endpoint
# File lib/stub_requests/endpoint.rb, line 64 def initialize(endpoint_id:, service_id:, service_uri:, verb:, path:) self.id = endpoint_id self.verb = verb self.path = path @service_id = service_id @service_uri = service_uri @uri = URI.safe_join(service_uri, path) @route_params = URI.route_params(path) @stubs = Concurrent::Array.new end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/stub_requests/endpoint.rb, line 91 def <=>(other) service_id <=> other.service_id && id <=> other.id end
hash()
click to toggle source
# File lib/stub_requests/endpoint.rb, line 96 def hash [id, self.class].hash end
to_s()
click to toggle source
Returns a descriptive string of this endpoint
@return [String]
# File lib/stub_requests/endpoint.rb, line 107 def to_s "#<#{self.class} id=:#{id} verb=:#{verb} path='#{path}'>" end
update(verb, path)
click to toggle source
Updates this endpoint
@param [Symbol] verb a HTTP verb @param [String] path how to reach the endpoint
@return [Endpoint] returns the updated endpoint
# File lib/stub_requests/endpoint.rb, line 85 def update(verb, path) @verb = verb @path = path self end