Class: HttpSimulator::Endpoint
- Inherits:
-
Object
- Object
- HttpSimulator::Endpoint
- Defined in:
- lib/endpoint.rb
Constant Summary collapse
- @@supported_methods =
['GET', 'PUT', 'PATCH', 'POST', 'DELETE']
Instance Attribute Summary collapse
-
#default_response ⇒ Object
readonly
Returns the value of attribute default_response.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#requests ⇒ Object
Returns the value of attribute requests.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #add_request(request) ⇒ Object
-
#initialize(method, path, default_response) ⇒ Endpoint
constructor
A new instance of Endpoint.
Constructor Details
#initialize(method, path, default_response) ⇒ Endpoint
Returns a new instance of Endpoint.
8 9 10 11 12 13 14 15 16 |
# File 'lib/endpoint.rb', line 8 def initialize(method, path, default_response) raise "Unsupported method #{method}" unless @@supported_methods.include? method @method = method @path = path @response = default_response @default_response = default_response @requests = [] end |
Instance Attribute Details
#default_response ⇒ Object (readonly)
Returns the value of attribute default_response.
3 4 5 |
# File 'lib/endpoint.rb', line 3 def default_response @default_response end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/endpoint.rb', line 3 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/endpoint.rb', line 3 def path @path end |
#requests ⇒ Object
Returns the value of attribute requests.
4 5 6 |
# File 'lib/endpoint.rb', line 4 def requests @requests end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/endpoint.rb', line 4 def response @response end |
Instance Method Details
#add_request(request) ⇒ Object
18 19 20 |
# File 'lib/endpoint.rb', line 18 def add_request(request) @requests.push request end |