module HTTParty::ClassMethods
def default_params(h = {})
default_params api_key: 'secret', another: 'foo'
include HTTParty
class Foo
Great for api keys and such.
Allows setting default parameters to be appended to each request.
def default_params(h = {}) raise ArgumentError, 'Default params must be an object which responds to #to_hash' unless h.respond_to?(:to_hash) default_options[:default_params] ||= {} default_options[:default_params].merge!(h) end