Class: RackDoubles::Client
- Inherits:
-
Object
- Object
- RackDoubles::Client
- Defined in:
- lib/rack_doubles/client.rb
Defined Under Namespace
Classes: Server
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Class Method Summary collapse
Instance Method Summary collapse
- #delete(resource) ⇒ Object
- #delete_all ⇒ Object
-
#initialize(server, http_client = RestClient) ⇒ Client
constructor
A new instance of Client.
- #stub(resource) ⇒ Object
- #url_for(path) ⇒ Object
Constructor Details
#initialize(server, http_client = RestClient) ⇒ Client
Returns a new instance of Client.
14 15 16 17 |
# File 'lib/rack_doubles/client.rb', line 14 def initialize(server, http_client = RestClient) @server = server @http_client = http_client end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
8 9 10 |
# File 'lib/rack_doubles/client.rb', line 8 def server @server end |
Class Method Details
Instance Method Details
#delete(resource) ⇒ Object
23 24 25 |
# File 'lib/rack_doubles/client.rb', line 23 def delete resource @http_client.delete url_for(resource) end |
#delete_all ⇒ Object
27 28 29 |
# File 'lib/rack_doubles/client.rb', line 27 def delete_all @http_client.delete url_for('/') end |
#stub(resource) ⇒ Object
19 20 21 |
# File 'lib/rack_doubles/client.rb', line 19 def stub resource @stub = Stub.new url_for(resource), @http_client end |
#url_for(path) ⇒ Object
31 32 33 |
# File 'lib/rack_doubles/client.rb', line 31 def url_for path "#{server.url}/#{path.gsub(/^\/+/, '')}" end |