lib/nightcrawler_swift/command.rb in nightcrawler_swift-0.7.0 vs lib/nightcrawler_swift/command.rb in nightcrawler_swift-0.8.0

- old
+ new

@@ -17,22 +17,26 @@ end # :nocov: protected - def get url, args = {} - prepare_args args - Gateway.new(url).request {|r| r.get headers_and_params(args)} + [ + :get, + :head, + :delete + ].each do |http_verb| + define_method http_verb do |*method_args| + url = method_args[0] + args = method_args[1] || {} + + prepare_args args + Gateway.new(url).request {|r| r.send(http_verb, headers_and_params(args))} + end end def put url, args = {} prepare_args args Gateway.new(url).request {|r| r.put args[:body], headers_and_params(args)} - end - - def delete url, args = {} - prepare_args args - Gateway.new(url).request {|r| r.delete headers_and_params(args)} end private def prepare_args args args[:headers] ||= {}