module Saddle::Options

Public Instance Methods

add_middleware(m) click to toggle source

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
default_options() click to toggle source

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
extra_env() click to toggle source

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
host() click to toggle source

The default host for this client

# File lib/saddle/options.rb, line 26
def host
  'localhost'
end
http_adapter() click to toggle source

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
num_retries() click to toggle source

Default number of retries per request

# File lib/saddle/options.rb, line 52
def num_retries
  1
end
path_prefix() click to toggle source

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
port() click to toggle source

The default port for this client

# File lib/saddle/options.rb, line 31
def port
  nil
end
request_style() click to toggle source

The POST/PUT style for this client options are [:json, :urlencoded]

# File lib/saddle/options.rb, line 47
def request_style
  :json
end
return_full_response() click to toggle source

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
stubs() click to toggle source

If the Typhoeus adapter is being used, pass stubs to it for testing.

# File lib/saddle/options.rb, line 73
def stubs
  nil
end
timeout() click to toggle source

Default timeout per request (in seconds)

# File lib/saddle/options.rb, line 57
def timeout
  30
end
use_ssl() click to toggle source

Should this client use SSL by default?

# File lib/saddle/options.rb, line 41
def use_ssl
  false
end