Method: HTTParty::ClassMethods#default_params
- Defined in:
- lib/httparty.rb
#default_params(h = {}) ⇒ Object
Allows setting default parameters to be appended to each request. Great for api keys and such.
class Foo
include HTTParty
default_params api_key: 'secret', another: 'foo'
end
161 162 163 164 165 |
# File 'lib/httparty.rb', line 161 def default_params(h={}) raise ArgumentError, 'Default params must an object which respond to #to_hash' unless h.respond_to?(:to_hash) [:default_params] ||= {} [:default_params].merge!(h) end |