lib/relax/performer.rb in tylerhunt-relax-0.1.2 vs lib/relax/performer.rb in tylerhunt-relax-0.1.3
- old
+ new
@@ -2,10 +2,11 @@
class Performer
def initialize(method, url, values, options={})
@method = method
@url = url
@values = values
+ @logger = options.delete(:logger)
@credentials = options.delete(:credentials)
@proxy = options.delete(:proxy)
@options = options
parse_url_tokens
@@ -13,11 +14,15 @@
def perform
RestClient.proxy = @proxy if @proxy
case @method
- when :delete, :get, :head then RestClient.send(@method, url)
- when :post, :put then RestClient.send(@method, url, query)
+ when :delete, :get, :head
+ @logger.info "#{@method.to_s.upcase} #{url}" if @logger
+ RestClient.send(@method, url)
+ when :post, :put
+ @logger.info "#{@method.to_s.upcase} #{url}\n#{query}" if @logger
+ RestClient.send(@method, url, query)
end
end
def url
url = @url.gsub(/\:[a-z_]+/) do |name|