Class: FakeServer::RemoteAPI
- Inherits:
-
Object
- Object
- FakeServer::RemoteAPI
- Defined in:
- lib/fake_server/remote_api.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
-
#initialize(host) ⇒ RemoteAPI
constructor
A new instance of RemoteAPI.
- #request(method, relative_url) ⇒ Object
Constructor Details
#initialize(host) ⇒ RemoteAPI
Returns a new instance of RemoteAPI.
5 6 7 8 |
# File 'lib/fake_server/remote_api.rb', line 5 def initialize(host) @host = host @host = "http://#{host}" unless host[/\Ahttp/] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/fake_server/remote_api.rb', line 10 def host @host end |
Instance Method Details
#request(method, relative_url) ⇒ Object
12 13 14 15 16 |
# File 'lib/fake_server/remote_api.rb', line 12 def request(method, relative_url) response = HTTParty.public_send(method.downcase, "#{host}#{relative_url}") response.headers.delete 'transfer-encoding' [response.code, response.headers, [response.body]] end |