Sha256: dec934a9e9f0e7e8bb9426fc990edfa7a2758777bd4d8367272aaf0cbde7ccbd

Contents?: true

Size: 1.67 KB

Versions: 6

Compression:

Stored size: 1.67 KB

Contents

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

module Saddle
  module Options

    # Construct our default options, based upon the class methods
    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,
        :http_adapter => http_adapter,
        :stubs => stubs,
        :additional_middlewares => self.additional_middlewares,
      }
    end

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

    # The default port for this client
    def port
      nil
    end

    # A string prefix to prepend to paths as they are build (ie, 'v1')
    def path_prefix
      nil
    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
      1
    end

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

    # Support specification of the HTTP adapter being used
    def http_adapter
      :net_http
    end

    # If the Typhoeus adapter is being used, pass stubs to it for testing.
    def stubs
      nil
    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

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
saddle-0.0.46 lib/saddle/options.rb
saddle-0.0.45 lib/saddle/options.rb
saddle-0.0.44 lib/saddle/options.rb
saddle-0.0.43 lib/saddle/options.rb
saddle-0.0.42 lib/saddle/options.rb
saddle-0.0.41 lib/saddle/options.rb