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
32 33 34 35 |
# File 'lib/httparty.rb', line 32 def base_uri(uri=nil) return [:base_uri] unless uri [:base_uri] = HTTParty.normalize_base_uri(uri) end |
#basic_auth(u, p) ⇒ Object
37 38 39 |
# File 'lib/httparty.rb', line 37 def basic_auth(u, p) [:basic_auth] = {:username => u, :password => p} end |
#default_options ⇒ Object
23 24 25 |
# File 'lib/httparty.rb', line 23 def @default_options end |
#default_params(h = {}) ⇒ Object
41 42 43 44 45 |
# File 'lib/httparty.rb', line 41 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
70 71 72 |
# File 'lib/httparty.rb', line 70 def delete(path, ={}) perform_request Net::HTTP::Delete, path, end |
#format(f) ⇒ Object
53 54 55 56 |
# File 'lib/httparty.rb', line 53 def format(f) raise UnsupportedFormat, "Must be one of: #{AllowedFormats.keys.join(', ')}" unless AllowedFormats.key?(f) [:format] = f end |
#get(path, options = {}) ⇒ Object
58 59 60 |
# File 'lib/httparty.rb', line 58 def get(path, ={}) perform_request Net::HTTP::Get, path, end |
#headers(h = {}) ⇒ Object
47 48 49 50 51 |
# File 'lib/httparty.rb', line 47 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
27 28 29 30 |
# File 'lib/httparty.rb', line 27 def http_proxy(addr=nil, port = nil) [:http_proxyaddr] = addr [:http_proxyport] = port end |
#post(path, options = {}) ⇒ Object
62 63 64 |
# File 'lib/httparty.rb', line 62 def post(path, ={}) perform_request Net::HTTP::Post, path, end |
#put(path, options = {}) ⇒ Object
66 67 68 |
# File 'lib/httparty.rb', line 66 def put(path, ={}) perform_request Net::HTTP::Put, path, end |