module Saddle::Options
Public Instance Methods
Use this to add additional middleware to the request stack ex: add_middleware
({
:klass => MyMiddleware, :args => [arg1, arg2],
}) end
# File lib/saddle/options.rb, line 91 def add_middleware m self.additional_middlewares << m end
Construct our default options, based upon the class methods
# File lib/saddle/options.rb, line 8 def default_options { :host => host, :port => port, :path_prefix => path_prefix, :use_ssl => use_ssl, :request_style => request_style, :num_retries => num_retries, :timeout => timeout, :extra_env => extra_env, :http_adapter => http_adapter, :stubs => stubs, :return_full_response => return_full_response, :additional_middlewares => self.additional_middlewares } end
If we need to load more into env before it passes to the adapter, use this
# File lib/saddle/options.rb, line 62 def extra_env {} end
The default host for this client
# File lib/saddle/options.rb, line 26 def host 'localhost' end
Support specification of the HTTP adapter being used. Returns a symbol or hash of the form { :key => :net_http, :args => [ … ] }.
# File lib/saddle/options.rb, line 68 def http_adapter { :key => :net_http, :args => [] } end
Default number of retries per request
# File lib/saddle/options.rb, line 52 def num_retries 1 end
A string prefix to prepend to paths as they are build (ie, ‘v1’)
# File lib/saddle/options.rb, line 36 def path_prefix nil end
The default port for this client
# File lib/saddle/options.rb, line 31 def port nil end
The POST/PUT style for this client options are [:json, :urlencoded]
# File lib/saddle/options.rb, line 47 def request_style :json end
Should the client return the full response object, or just the body?
# File lib/saddle/options.rb, line 78 def return_full_response false end
If the Typhoeus adapter is being used, pass stubs to it for testing.
# File lib/saddle/options.rb, line 73 def stubs nil end
Default timeout per request (in seconds)
# File lib/saddle/options.rb, line 57 def timeout 30 end
Should this client use SSL by default?
# File lib/saddle/options.rb, line 41 def use_ssl false end