Sha256: 62b45eabf42d3ed32821c704845bada01f2973c6ff7efb8a89a222aa00f7d457

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

module Attune
  module Configurable
    KEYS = [
      :auth_token,
      :endpoint,
      :middleware,
      :disabled,
      :exception_handler,
      :timeout
    ]

    # The Authorization token
    attr_accessor :auth_token

    # The HTTP endpoint to connect to
    attr_accessor :endpoint

    # Middleware used by faraday
    attr_accessor :middleware

    # FIXME
    attr_accessor :disabled
    alias_method :disabled?, :disabled

    # Time (in seconds) to wait for requests to finish
    attr_accessor :timeout

    # How to deal with HTTP exceptions
    # @param [:mock, :raise] handler Method used for handling exceptions.
    # @raise [ArgumentError] if handler is not :mock or :raise
    attr_reader :exception_handler
    def exception_handler= handler
      if [:mock, :raise].include?(handler)
        @exception_handler = handler
      else
        raise ArgumentError, "exception_handler must be :mock or :raise"
      end
    end

    # @example configure
    #   Attune.configure do |c|
    #     c.endpoint = "http://example.com:8080/"
    #     c.timeout  = 5
    #   end
    def configure
      yield self
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
attune-1.0.3 lib/attune/configurable.rb
attune-1.0.2 lib/attune/configurable.rb
attune-1.0.1 lib/attune/configurable.rb
attune-1.0.0 lib/attune/configurable.rb
attune-0.0.7 lib/attune/configurable.rb
attune-0.0.6 lib/attune/configurable.rb
attune-0.0.5 lib/attune/configurable.rb
attune-0.0.4 lib/attune/configurable.rb