lib/mudbug.rb in mudbug-0.6.0.1 vs lib/mudbug.rb in mudbug-0.7.0.1
- old
+ new
@@ -82,12 +82,10 @@
attr_reader :options
attr_accessor :host
def initialize(host, options = {})
- # note, not yet logging at instance layer
- # @lager = self.class.lager
@host = host
@options = options
accept :json, :html, :text
end
@@ -105,13 +103,21 @@
@options[:headers][:accept] = self.class.accept_header(*types)
end
# use this method directly if you want finer-grained request and response
# handling
+ # supports /path/to/res, path/to/res, http://host.com/path/to/res
#
def resource(path, options = {})
- path = "/#{path}" unless path[0,1] == '/'
- RestClient::Resource.new "http://#{@host}#{path}", @options.merge(options)
+ uri = URI.parse(path)
+ if uri.host # a full URL was passed in
+ @host = uri.host
+ url = uri.to_s
+ else
+ path = "/#{path}" unless path[0,1] == '/'
+ url = "http://#{@host}#{path}"
+ end
+ RestClient::Resource.new url, @options.merge(options)
end
# no payload
#
[:get, :delete].each { |meth|