lib/rufus/verbs/endpoint.rb in rufus-verbs-0.7 vs lib/rufus/verbs/endpoint.rb in rufus-verbs-0.8
- old
+ new
@@ -210,13 +210,16 @@
opts = {}
args = [ args ] unless args.is_a?(Array)
- opts = args.last if args.last.is_a?(Hash)
- opts[:uri] = args.first if args.first.is_a?(String)
+ opts = args.last \
+ if args.last.is_a?(Hash)
+ opts[:uri] = args.first \
+ if args.first.is_a?(String) or args.first.is_a?(URI)
+
opts
end
#
# Returns the value from the [request] opts or from the
@@ -295,13 +298,13 @@
opts[:query][:_method] = method.to_s
method = :post
end
- p = compute_path opts
+ path = compute_path opts
- r = eval("Net::HTTP::#{method.to_s.capitalize}").new p
+ r = eval("Net::HTTP::#{method.to_s.capitalize}").new path
r['User-Agent'] = o(opts, :user_agent)
# potentially overriden by opts[:headers]
h = opts[:headers] || opts[:h]
@@ -418,12 +421,10 @@
b = o(opts, :base)
r = o(opts, [ :res, :resource ])
i = o(opts, :id)
- p = o(opts, :path)
-
- path = p
+ path = o(opts, :path)
if b or r or i
path = ""
path = "/#{b}" if b
path += "/#{r}" if r