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
- #post(path, options = {}) ⇒ Object
- #put(path, options = {}) ⇒ Object
Instance Method Details
#base_uri(uri = nil) ⇒ Object
40 41 42 43 |
# File 'lib/httparty.rb', line 40 def base_uri(uri=nil) return [:base_uri] unless uri [:base_uri] = HTTParty.normalize_base_uri(uri) end |
#basic_auth(u, p) ⇒ Object
45 46 47 |
# File 'lib/httparty.rb', line 45 def basic_auth(u, p) [:basic_auth] = {:username => u, :password => p} end |
#default_options ⇒ Object
31 32 33 |
# File 'lib/httparty.rb', line 31 def @default_options end |
#default_params(h = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/httparty.rb', line 49 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
78 79 80 |
# File 'lib/httparty.rb', line 78 def delete(path, ={}) perform_request Net::HTTP::Delete, path, end |
#format(f) ⇒ Object
61 62 63 64 |
# File 'lib/httparty.rb', line 61 def format(f) raise UnsupportedFormat, "Must be one of: #{AllowedFormats.values.join(', ')}" unless AllowedFormats.value?(f) [:format] = f end |
#get(path, options = {}) ⇒ Object
66 67 68 |
# File 'lib/httparty.rb', line 66 def get(path, ={}) perform_request Net::HTTP::Get, path, end |
#headers(h = {}) ⇒ Object
55 56 57 58 59 |
# File 'lib/httparty.rb', line 55 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
35 36 37 38 |
# File 'lib/httparty.rb', line 35 def http_proxy(addr=nil, port = nil) [:http_proxyaddr] = addr [:http_proxyport] = port end |
#post(path, options = {}) ⇒ Object
70 71 72 |
# File 'lib/httparty.rb', line 70 def post(path, ={}) perform_request Net::HTTP::Post, path, end |
#put(path, options = {}) ⇒ Object
74 75 76 |
# File 'lib/httparty.rb', line 74 def put(path, ={}) perform_request Net::HTTP::Put, path, end |