Module: Saddle::Options
- Included in:
- Client
- Defined in:
- lib/saddle/options.rb
Instance Method Summary collapse
-
#add_middleware(m) ⇒ Object
Use this to add additional middleware to the request stack ex: add_middleware({ :klass => MyMiddleware, :args => [arg1, arg2], }) end.
-
#default_options ⇒ Object
Construct our default options, based upon the class methods.
-
#extra_env ⇒ Object
If we need to load more into env before it passes to the adapter, use this.
-
#host ⇒ Object
The default host for this client.
-
#http_adapter ⇒ Object
Support specification of the HTTP adapter being used.
-
#num_retries ⇒ Object
Default number of retries per request.
-
#path_prefix ⇒ Object
A string prefix to prepend to paths as they are build (ie, ‘v1’).
-
#port ⇒ Object
The default port for this client.
-
#request_style ⇒ Object
The POST/PUT style for this client options are [:json, :urlencoded].
-
#return_full_response ⇒ Object
Should the client return the full response object, or just the body?.
-
#stubs ⇒ Object
If the Typhoeus adapter is being used, pass stubs to it for testing.
-
#timeout ⇒ Object
Default timeout per request (in seconds).
-
#use_ssl ⇒ Object
Should this client use SSL by default?.
Instance Method Details
#add_middleware(m) ⇒ Object
Use this to add additional middleware to the request stack ex: add_middleware(
:klass => MyMiddleware,
:args => [arg1, arg2],
) end
91 92 93 |
# File 'lib/saddle/options.rb', line 91 def add_middleware m self.additional_middlewares << m end |
#default_options ⇒ Object
Construct our default options, based upon the class methods
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/saddle/options.rb', line 8 def { :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 |
#extra_env ⇒ Object
If we need to load more into env before it passes to the adapter, use this
62 63 64 |
# File 'lib/saddle/options.rb', line 62 def extra_env {} end |
#host ⇒ Object
The default host for this client
26 27 28 |
# File 'lib/saddle/options.rb', line 26 def host 'localhost' end |
#http_adapter ⇒ Object
Support specification of the HTTP adapter being used. Returns a symbol or hash of the form { :key => :net_http, :args => [ … ] }.
68 69 70 |
# File 'lib/saddle/options.rb', line 68 def http_adapter { :key => :net_http, :args => [] } end |
#num_retries ⇒ Object
Default number of retries per request
52 53 54 |
# File 'lib/saddle/options.rb', line 52 def num_retries 1 end |
#path_prefix ⇒ Object
A string prefix to prepend to paths as they are build (ie, ‘v1’)
36 37 38 |
# File 'lib/saddle/options.rb', line 36 def path_prefix nil end |
#port ⇒ Object
The default port for this client
31 32 33 |
# File 'lib/saddle/options.rb', line 31 def port nil end |
#request_style ⇒ Object
The POST/PUT style for this client options are [:json, :urlencoded]
47 48 49 |
# File 'lib/saddle/options.rb', line 47 def request_style :json end |
#return_full_response ⇒ Object
Should the client return the full response object, or just the body?
78 79 80 |
# File 'lib/saddle/options.rb', line 78 def return_full_response false end |
#stubs ⇒ Object
If the Typhoeus adapter is being used, pass stubs to it for testing.
73 74 75 |
# File 'lib/saddle/options.rb', line 73 def stubs nil end |
#timeout ⇒ Object
Default timeout per request (in seconds)
57 58 59 |
# File 'lib/saddle/options.rb', line 57 def timeout 30 end |
#use_ssl ⇒ Object
Should this client use SSL by default?
41 42 43 |
# File 'lib/saddle/options.rb', line 41 def use_ssl false end |