Sha256: bd250cb65f0d413eeaf7319512b92055cdac70b8c8d700d525d36cf9cf5cee4e

Contents?: true

Size: 683 Bytes

Versions: 3

Compression:

Stored size: 683 Bytes

Contents

class URL
  # Typhoeus handler
  class TyHandler < RequestHandler
    
    def get(args={})
      resp = Typhoeus::Request.get(url.to_s)
      
      make_str(resp)
    end
    
    def post(args={})
      resp = Typhoeus::Request.post(url.to_s(:params => false), :params => url.params)
      
      make_str(resp)
    end
    
    def delete(args={})
      resp = Typhoeus::Request.delete(url.to_s)
      make_str(resp)
    end
    
  private
    
    def make_str(resp)
      hsh = {
        :code => resp.code,
        :time => resp.time,
        :body => resp.body,
        :response => resp,
        :url => url.to_s
      }
      
      Response.new(hsh)
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
url-0.2.2 lib/url/handlers/ty_handler.rb
url-0.2.1 lib/url/handlers/ty_handler.rb
url-0.2.0 lib/url/handlers/ty_handler.rb