Class: Apipony::Endpoint
Overview
Model a response endpoint.
Instance Attribute Summary collapse
-
#description ⇒ Object
A short description of what this endpoint does and why it may be useful.
-
#method ⇒ Object
What HTTP verb to use to access this endpoint.
-
#request ⇒ Object
:nodoc:.
-
#response ⇒ Object
:nodoc:.
-
#url ⇒ Object
The URl of this endpoint.
Instance Method Summary collapse
-
#id ⇒ Object
Create a unique identifier for this endpoint.
-
#initialize(method, url, &block) ⇒ Endpoint
constructor
A new instance of Endpoint.
-
#request_with(&block) ⇒ Object
DSL method to start describind a request.
-
#response_with(status, **params, &block) ⇒ Object
DSL method to start describing a response.
Constructor Details
#initialize(method, url, &block) ⇒ Endpoint
Returns a new instance of Endpoint.
19 20 21 22 23 24 |
# File 'lib/apipony/endpoint.rb', line 19 def initialize(method, url, &block) @method = method @url = set_base_url(url) instance_eval(&block) if block_given? end |
Instance Attribute Details
#description ⇒ Object
A short description of what this endpoint does and why it may be useful.
13 14 15 |
# File 'lib/apipony/endpoint.rb', line 13 def description @description end |
#method ⇒ Object
What HTTP verb to use to access this endpoint
6 7 8 |
# File 'lib/apipony/endpoint.rb', line 6 def method @method end |
#request ⇒ Object
:nodoc:
17 18 19 |
# File 'lib/apipony/endpoint.rb', line 17 def request @request end |
#response ⇒ Object
:nodoc:
17 18 19 |
# File 'lib/apipony/endpoint.rb', line 17 def response @response end |
#url ⇒ Object
The URl of this endpoint
9 10 11 |
# File 'lib/apipony/endpoint.rb', line 9 def url @url end |
Instance Method Details
#id ⇒ Object
Create a unique identifier for this endpoint
40 41 42 |
# File 'lib/apipony/endpoint.rb', line 40 def id File.join(@method.to_s, @url) end |