Module: Saddle::Options

Included in:
Client
Defined in:
lib/saddle/options.rb

Instance Method Summary collapse

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_optionsObject

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 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_envObject

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

#hostObject

The default host for this client



26
27
28
# File 'lib/saddle/options.rb', line 26

def host
  'localhost'
end

#http_adapterObject

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_retriesObject

Default number of retries per request



52
53
54
# File 'lib/saddle/options.rb', line 52

def num_retries
  1
end

#path_prefixObject

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

#portObject

The default port for this client



31
32
33
# File 'lib/saddle/options.rb', line 31

def port
  nil
end

#request_styleObject

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_responseObject

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

#stubsObject

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

#timeoutObject

Default timeout per request (in seconds)



57
58
59
# File 'lib/saddle/options.rb', line 57

def timeout
  30
end

#use_sslObject

Should this client use SSL by default?



41
42
43
# File 'lib/saddle/options.rb', line 41

def use_ssl
  false
end