1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Fix for 1.9.2. Closes #46

This commit is contained in:
Julien Kirch 2010-11-04 21:02:00 +01:00
parent 9e05961278
commit 6ae3e1b005

View file

@ -13,7 +13,9 @@ def usage(why = nil)
exit(1) exit(1)
end end
if %w( get put post delete ).include? ARGV.first POSSIBLE_VERBS = ['get', 'put', 'post', 'delete']
if POSSIBLE_VERBS.include? ARGV.first
@verb = ARGV.shift @verb = ARGV.shift
else else
@verb = nil @verb = nil
@ -52,7 +54,7 @@ if @verb
end end
end end
%w( get post put delete ).each do |m| POSSIBLE_VERBS.each do |m|
eval <<-end_eval eval <<-end_eval
def #{m} (path, *args, &b) def #{m} (path, *args, &b)
r[path]. #{m} (*args, &b) r[path]. #{m} (*args, &b)
@ -61,12 +63,15 @@ end
end end
def method_missing(s, * args, & b) def method_missing(s, * args, & b)
super unless r.respond_to?(s) if POSSIBLE_VERBS.include? s
begin begin
r.send(s, * args, & b) r.send(s, * args, & b)
rescue RestClient::RequestFailed => e rescue RestClient::RequestFailed => e
print STDERR, e.response.body print STDERR, e.response.body
raise e raise e
end
else
super
end end
end end