From 6ae3e1b005638c1bc966f5347346d3c22308dff3 Mon Sep 17 00:00:00 2001 From: Julien Kirch Date: Thu, 4 Nov 2010 21:02:00 +0100 Subject: [PATCH] Fix for 1.9.2. Closes #46 --- bin/restclient | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/restclient b/bin/restclient index 3e670f0..63d5fc0 100755 --- a/bin/restclient +++ b/bin/restclient @@ -13,7 +13,9 @@ def usage(why = nil) exit(1) 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 else @verb = nil @@ -52,7 +54,7 @@ if @verb end end -%w( get post put delete ).each do |m| +POSSIBLE_VERBS.each do |m| eval <<-end_eval def #{m} (path, *args, &b) r[path]. #{m} (*args, &b) @@ -61,12 +63,15 @@ end end def method_missing(s, * args, & b) - super unless r.respond_to?(s) - begin - r.send(s, * args, & b) - rescue RestClient::RequestFailed => e - print STDERR, e.response.body - raise e + if POSSIBLE_VERBS.include? s + begin + r.send(s, * args, & b) + rescue RestClient::RequestFailed => e + print STDERR, e.response.body + raise e + end + else + super end end