Sha256: a68c4b14b2c846f30cca8bcc30d0ea1193c10d8ae27164d035446cdfb7dce527

Contents?: true

Size: 1.69 KB

Versions: 10

Compression:

Stored size: 1.69 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,
        :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
      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
      3
    end

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

    # If you want to set up an ActiveSupport::Notification, give your client
    #  an instrumentation key to monitor.
    def instrumentation_key
      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

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

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
saddle-0.0.36 lib/saddle/options.rb
saddle-0.0.35 lib/saddle/options.rb
saddle-0.0.34 lib/saddle/options.rb
saddle-0.0.33 lib/saddle/options.rb
saddle-0.0.32 lib/saddle/options.rb
saddle-0.0.31 lib/saddle/options.rb
saddle-0.0.30 lib/saddle/options.rb
saddle-0.0.27 lib/saddle/options.rb
saddle-0.0.26 lib/saddle/options.rb
saddle-0.0.25 lib/saddle/options.rb