Module: HTTParty::ClassMethods
- Defined in:
- lib/httparty.rb
Instance Method Summary collapse
- #base_uri(uri = nil) ⇒ Object
- #basic_auth(u, p) ⇒ Object
- #default_options ⇒ Object
- #default_params(h = {}) ⇒ Object
- #delete(path, options = {}) ⇒ Object
- #format(f) ⇒ Object
- #get(path, options = {}) ⇒ Object
- #headers(h = {}) ⇒ Object
-
#http_proxy(addr = nil, port = nil) ⇒ Object
Set an http proxy.
- #post(path, options = {}) ⇒ Object
- #put(path, options = {}) ⇒ Object
Instance Method Details
#base_uri(uri = nil) ⇒ Object
69 70 71 72 |
# File 'lib/httparty.rb', line 69 def base_uri(uri=nil) return [:base_uri] unless uri [:base_uri] = normalize_base_uri(uri) end |
#basic_auth(u, p) ⇒ Object
74 75 76 |
# File 'lib/httparty.rb', line 74 def basic_auth(u, p) [:basic_auth] = {:username => u, :password => p} end |
#default_options ⇒ Object
53 54 55 |
# File 'lib/httparty.rb', line 53 def @default_options end |
#default_params(h = {}) ⇒ Object
78 79 80 81 82 |
# File 'lib/httparty.rb', line 78 def default_params(h={}) raise ArgumentError, 'Default params must be a hash' unless h.is_a?(Hash) [:default_params] ||= {} [:default_params].merge!(h) end |
#delete(path, options = {}) ⇒ Object
107 108 109 |
# File 'lib/httparty.rb', line 107 def delete(path, ={}) perform_request Net::HTTP::Delete, path, end |
#format(f) ⇒ Object
90 91 92 93 |
# File 'lib/httparty.rb', line 90 def format(f) raise UnsupportedFormat, "Must be one of: #{AllowedFormats.keys.join(', ')}" unless AllowedFormats.key?(f) [:format] = f end |
#get(path, options = {}) ⇒ Object
95 96 97 |
# File 'lib/httparty.rb', line 95 def get(path, ={}) perform_request Net::HTTP::Get, path, end |
#headers(h = {}) ⇒ Object
84 85 86 87 88 |
# File 'lib/httparty.rb', line 84 def headers(h={}) raise ArgumentError, 'Headers must be a hash' unless h.is_a?(Hash) [:headers] ||= {} [:headers].merge!(h) end |
#http_proxy(addr = nil, port = nil) ⇒ Object
64 65 66 67 |
# File 'lib/httparty.rb', line 64 def http_proxy(addr=nil, port = nil) [:http_proxyaddr] = addr [:http_proxyport] = port end |
#post(path, options = {}) ⇒ Object
99 100 101 |
# File 'lib/httparty.rb', line 99 def post(path, ={}) perform_request Net::HTTP::Post, path, end |
#put(path, options = {}) ⇒ Object
103 104 105 |
# File 'lib/httparty.rb', line 103 def put(path, ={}) perform_request Net::HTTP::Put, path, end |