Class: HttpSimulator::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/endpoint.rb

Constant Summary collapse

@@supported_methods =
['GET', 'PUT', 'PATCH', 'POST', 'DELETE']

Instance Attribute Summary collapse

Instance Method Summary collapse

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_responseObject (readonly)

Returns the value of attribute default_response.



3
4
5
# File 'lib/endpoint.rb', line 3

def default_response
  @default_response
end

#methodObject (readonly)

Returns the value of attribute method.



3
4
5
# File 'lib/endpoint.rb', line 3

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/endpoint.rb', line 3

def path
  @path
end

#requestsObject

Returns the value of attribute requests.



4
5
6
# File 'lib/endpoint.rb', line 4

def requests
  @requests
end

#responseObject

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