Class: FakeServer::RemoteAPI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ RemoteAPI

Returns a new instance of RemoteAPI.



5
6
7
# File 'lib/fake_server/remote_api.rb', line 5

def initialize(host)
  @host = host
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



9
10
11
# File 'lib/fake_server/remote_api.rb', line 9

def host
  @host
end

Instance Method Details

#request(method, relative_url) ⇒ Object



11
12
13
14
# File 'lib/fake_server/remote_api.rb', line 11

def request(method, relative_url)
  response = HTTParty.public_send(method.downcase, "#{host}#{relative_url}")
  [response.code, response.headers, [response.body]]
end