Class: StubRequests::Endpoint
- Includes:
- Comparable, Concerns::Property
- Defined in:
- lib/stub_requests/endpoint.rb
Overview
Class Endpoint provides registration of stubbed endpoints
Instance Attribute Summary collapse
-
#id ⇒ Symbol
The id of the endpoint.
-
#path ⇒ String
A string template for the endpoint.
- #route_params ⇒ Object
- #service_id ⇒ Object
- #service_uri ⇒ Object
- #uri ⇒ Object
-
#verb ⇒ Symbol
A HTTP verb.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(endpoint_id:, service_id:, service_uri:, verb:, path:) ⇒ Endpoint
constructor
Initialize an endpoint for a specific Service.
-
#to_s ⇒ String
Returns a descriptive string of this endpoint.
-
#update(verb, path) ⇒ Endpoint
Updates this endpoint.
Methods included from Concerns::Property
Methods included from Concerns::ArgumentValidation
Constructor Details
#initialize(endpoint_id:, service_id:, service_uri:, verb:, path:) ⇒ Endpoint
Initialize an endpoint for a specific Service
64 65 66 67 68 69 70 71 72 73 74 |
# 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 |
Instance Attribute Details
#id ⇒ Symbol
Returns the id of the endpoint
25 |
# File 'lib/stub_requests/endpoint.rb', line 25 property :id, type: Symbol |
#path ⇒ String
Returns a string template for the endpoint
33 |
# File 'lib/stub_requests/endpoint.rb', line 33 property :path, type: String |
#route_params ⇒ Object
52 53 54 |
# File 'lib/stub_requests/endpoint.rb', line 52 def route_params @route_params end |
#service_id ⇒ Object
42 43 44 |
# File 'lib/stub_requests/endpoint.rb', line 42 def service_id @service_id end |
#service_uri ⇒ Object
47 48 49 |
# File 'lib/stub_requests/endpoint.rb', line 47 def service_uri @service_uri end |
Instance Method Details
#<=>(other) ⇒ Object
91 92 93 94 |
# File 'lib/stub_requests/endpoint.rb', line 91 def <=>(other) service_id <=> other.service_id && id <=> other.id end |
#hash ⇒ Object
96 97 98 |
# File 'lib/stub_requests/endpoint.rb', line 96 def hash [id, self.class].hash end |
#to_s ⇒ String
Returns a descriptive string of this endpoint
107 108 109 |
# File 'lib/stub_requests/endpoint.rb', line 107 def to_s "#<#{self.class} id=:#{id} verb=:#{verb} path='#{path}'>" end |
#update(verb, path) ⇒ Endpoint
Updates this endpoint
85 86 87 88 89 |
# File 'lib/stub_requests/endpoint.rb', line 85 def update(verb, path) @verb = verb @path = path self end |