class RestClient::Resource
def [](suburl)
comments.post 'Hello', :content_type => 'text/plain'
comments = first_post['comments']
first_post = posts['1']
posts = site['posts']
site = RestClient::Resource.new('http://example.com')
Nest resources as far as you want:
orders['1/items'].delete # DELETE http://example.com/orders/1/items
orders['1'].get # GET http://example.com/orders/1
orders.get # GET http://example.com/orders
end
RestClient::Resource.new('http://example.com/orders', 'admin', 'mypasswd')
def orders
call it in multiple locations:
This is especially useful if you wish to define your site in one place and
site['posts/1/comments'].post 'Good article.', :content_type => 'text/plain'
site = RestClient::Resource.new('http://example.com', 'adam', 'mypasswd')
Example:
Construct a subresource, preserving authentication.
def [](suburl) self.class.new(concat_urls(url, suburl), options) end