Sha256: c045c16db98d9f2bd8270f86327bdd85907a70ed730b7238ef4f0d306b4537c4
Contents?: true
Size: 998 Bytes
Versions: 3
Compression:
Stored size: 998 Bytes
Contents
module Douban # Defines HTTP request methods module Request # Perform an HTTP GET request def get(path, options={}, raw=false) request(:get, path, options, raw) end # Perform an HTTP POST request def post(path, options={}, raw=false) request(:post, path, options, raw) end # Perform an HTTP PUT request def put(path, options={}, raw=false) request(:put, path, options, raw) end # Perform an HTTP DELETE request def delete(path, options={}, raw=false) request(:delete, path, options, raw) end private # Perform an HTTP request def request(method, path, options={}, raw=false) response = connection(raw).send(method) do |request| case method when :get, :delete request.url(path, options) when :post, :put request.path = path request.body = options unless options.empty? end end raw ? response : response.body end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
douban_api-0.1.2 | lib/douban_api/request.rb |
douban_api-0.1.1 | lib/douban_api/request.rb |
douban_api-0.1.0 | lib/douban_api/request.rb |