Sha256: 4cdec8f2ec185ac2344cfcbcb5f1368905800d9a552cec818ed3fbe73214f968

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents



# Default options for a client. Override whatever you need to for
# your specific implementation


module Saddle::Options

  # Construct our default options, based upon the class methods
  def default_options
    {
      :host => host,
      :port => port,
      :use_ssl => use_ssl,
      :request_style => request_style,
      :num_retries => num_retries,
      :timeout => timeout,
      :additional_middlewares => self.additional_middlewares,
      :stubs => stubs,
    }
  end

  # The default host for this client
  def host
    'localhost'
  end

  # The default port for this client
  def port
    80
  end

  # Should this client use SSL by default?
  def use_ssl
    false
  end

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

  # Default number of retries per request
  def num_retries
    3
  end

  # Default timeout per request (in seconds)
  def timeout
    30
  end

  # Use this to add additional middleware to the request stack
  # ex:
  # add_middleware({
  #   :klass => MyMiddleware,
  #   :args => [arg1, arg2],
  # })
  # end
  #
  ###  
  def add_middleware m
    self.additional_middlewares << m
  end

  # If the Typhoeus adapter is being used, pass stubs to it for testing.
  def stubs
    nil
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
saddle-0.0.12 lib/saddle/options.rb
saddle-0.0.11 lib/saddle/options.rb
saddle-0.0.10 lib/saddle/options.rb