Module: HTTParty::ClassMethods
- Defined in:
- lib/httparty.rb
Instance Method Summary collapse
- #base_uri(base_uri = nil) ⇒ Object
-
#basic_auth(u, p) ⇒ Object
Warning: This is not thread safe most likely and only works if you use one set of credentials.
-
#default_params(h = {}) ⇒ Object
Updates the default query string parameters that should be appended to each request.
-
#delete(path, options = {}) ⇒ Object
TODO: spec out this.
- #format(f) ⇒ Object
-
#get(path, options = {}) ⇒ Object
TODO: spec out this.
- #headers(h = {}) ⇒ Object
-
#http_proxy(addr = nil, port = nil) ⇒ Object
Set an http proxy.
-
#post(path, options = {}) ⇒ Object
TODO: spec out this.
-
#put(path, options = {}) ⇒ Object
TODO: spec out this.
Instance Method Details
#base_uri(base_uri = nil) ⇒ Object
34 35 36 37 |
# File 'lib/httparty.rb', line 34 def base_uri(base_uri=nil) return @base_uri unless base_uri @base_uri = normalize_base_uri(base_uri) end |
#basic_auth(u, p) ⇒ Object
Warning: This is not thread safe most likely and only works if you use one set of credentials. I leave it because it is convenient on some occasions.
42 43 44 |
# File 'lib/httparty.rb', line 42 def basic_auth(u, p) @auth = {:username => u, :password => p} end |
#default_params(h = {}) ⇒ Object
Updates the default query string parameters that should be appended to each request.
48 49 50 51 52 53 |
# File 'lib/httparty.rb', line 48 def default_params(h={}) raise ArgumentError, 'Default params must be a hash' unless h.is_a?(Hash) @default_params ||= {} return @default_params if h.blank? @default_params.merge!(h) end |
#delete(path, options = {}) ⇒ Object
TODO: spec out this
83 84 85 |
# File 'lib/httparty.rb', line 83 def delete(path, ={}) send_request 'delete', path, end |
#format(f) ⇒ Object
62 63 64 65 |
# File 'lib/httparty.rb', line 62 def format(f) raise UnsupportedFormat, "Must be one of: #{AllowedFormats.keys.join(', ')}" unless AllowedFormats.key?(f) @format = f end |
#get(path, options = {}) ⇒ Object
TODO: spec out this
68 69 70 |
# File 'lib/httparty.rb', line 68 def get(path, ={}) send_request 'get', path, end |
#headers(h = {}) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/httparty.rb', line 55 def headers(h={}) raise ArgumentError, 'Headers must be a hash' unless h.is_a?(Hash) @headers ||= {} return @headers if h.blank? @headers.merge!(h) end |
#http_proxy(addr = nil, port = nil) ⇒ Object
Set an http proxy
class Twitter
include HTTParty
http_proxy http://myProxy, 1080
.…
29 30 31 32 |
# File 'lib/httparty.rb', line 29 def http_proxy(addr=nil, port = nil) @http_proxyaddr = addr @http_proxyport = port end |
#post(path, options = {}) ⇒ Object
TODO: spec out this
73 74 75 |
# File 'lib/httparty.rb', line 73 def post(path, ={}) send_request 'post', path, end |
#put(path, options = {}) ⇒ Object
TODO: spec out this
78 79 80 |
# File 'lib/httparty.rb', line 78 def put(path, ={}) send_request 'put', path, end |