class Vertebrae::Configuration

Constants

DEFAULT_ADDITIONAL_HEADERS
DEFAULT_CONNECTION_OPTIONS

By default uses the Faraday connection options if none is set

DEFAULT_CONTENT_TYPE
DEFAULT_HOST

by default do not set a host. this is specific to AK instance

DEFAULT_MIME_TYPE

By default the Accept header will make a request for JSON

DEFAULT_PASSWORD

By default, don’t set a user password

DEFAULT_PORT

by default do not set a port so that it is not specified on endpoint

DEFAULT_PREFIX

The api endpoint used to connect to AK if none is set

DEFAULT_SCHEME

The default HTTP scheme configuration

DEFAULT_SSL

The default SSL configuration

DEFAULT_USERNAME

By default, don’t set a user ame

DEFAULT_USER_AGENT

The value sent in the http header for ‘User-Agent’ if none is set

VALID_OPTIONS_KEYS

Attributes

default_options[RW]
options[RW]

Public Class Methods

new(options) click to toggle source
# File lib/vertebrae/configuration.rb, line 84
def initialize(options)
  self.options = options
  self.default_options = {}

  VALID_OPTIONS_KEYS.each do |key|
    default_options[key] = "Vertebrae::Configuration::DEFAULT_#{key.to_s.upcase}".constantize
  end
end

Public Instance Methods

adapter() click to toggle source
# File lib/vertebrae/configuration.rb, line 73
def adapter
  options[:adapter] || ::Faraday.default_adapter
end
adapter=(value) click to toggle source
# File lib/vertebrae/configuration.rb, line 77
def adapter=(value)
  options[:adapter] = value
end
endpoint() click to toggle source
# File lib/vertebrae/configuration.rb, line 119
def endpoint
  "#{self.scheme}://#{self.host}#{self.port.present? ? ":#{self.port}" : ''}#{self.prefix}"
end
faraday_options() click to toggle source
# File lib/vertebrae/configuration.rb, line 93
def faraday_options
  {
    :headers => {
      ACCEPT           => "application/json;q=0.1",
      ACCEPT_CHARSET   => "utf-8",
      USER_AGENT       => user_agent,
      CONTENT_TYPE     => content_type
    }.merge(additional_headers),
    :ssl => ssl,
    :url => endpoint
  }.merge(connection_options)
end
process_basic_auth(auth) click to toggle source

Extract login and password from basic_auth parameter

# File lib/vertebrae/configuration.rb, line 109
def process_basic_auth(auth)
  case auth
    when String
      self.username, self.password = auth.split(':', 2)
    when Hash
      self.username = auth[:username]
      self.password = auth[:password]
  end
end