lib/restclient/resource.rb
def [](suburl, &new_block)
      case
      when block_given? then self.class.new(concat_urls(url, suburl), options, &new_block)
      when block        then self.class.new(concat_urls(url, suburl), options, &block)
      else                   self.class.new(concat_urls(url, suburl), options)
      end
    end
def [](suburl, &new_block)
      case
      when block_given? then self.class.new(concat_urls(url, suburl), options, &new_block)
      when block        then self.class.new(concat_urls(url, suburl), options, &block)
      else                   self.class.new(concat_urls(url, suburl), options)
      end
    end
def [] ( suburl , & new_block ) case when block_given? then self . class . new ( concat_urls ( url , suburl ) , options , new_block ) when block then self . class . new ( concat_urls ( url , suburl ) , options , block ) else self . class . new ( concat_urls ( url , suburl ) , options ) end end
Construct a subresource, preserving authentication.

 Example:

   site = RestClient::Resource.new('http://example.com', 'adam', 'mypasswd')
   site['posts/1/comments'].post 'Good article.', :content_type => 'text/plain'

 This is especially useful if you wish to define your site in one place and
 call it in multiple locations:

   def orders
     RestClient::Resource.new('http://example.com/orders', 'admin', 'mypasswd')
   end

   orders.get                     # GET http://example.com/orders
   orders['1'].get                # GET http://example.com/orders/1
   orders['1/items'].delete       # DELETE http://example.com/orders/1/items

 Nest resources as far as you want:

   site = RestClient::Resource.new('http://example.com')
   posts = site['posts']
   first_post = posts['1']
   comments = first_post['comments']
   comments.post 'Hello', :content_type => 'text/plain'
Construct a subresource preserving authentication .