Class: Vertebrae::Configuration
- Inherits:
-
Object
- Object
- Vertebrae::Configuration
- Includes:
- ActiveSupport::Inflector, Authorization, Constants
- Defined in:
- lib/configuration.rb
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :adapter, :prefix, :ssl, :mime_type, :user_agent, :host, :username, :password, :connection_options, :content_type, ].freeze
- DEFAULT_ADAPTER =
Other adapters are :typhoeus, :patron, :em_synchrony, :excon, :test
:net_http- DEFAULT_SSL =
The default SSL configuration
{}
- DEFAULT_MIME_TYPE =
By default the
Acceptheader will make a request forJSON :json- DEFAULT_USER_AGENT =
The value sent in the http header for ‘User-Agent’ if none is set
"Vertebrae REST Gem".freeze
- DEFAULT_HOST =
by default do not set a host. this is specific to AK instance
nil- DEFAULT_PREFIX =
The api endpoint used to connect to AK if none is set
'/'.freeze
- DEFAULT_USERNAME =
By default, don’t set a user ame
nil- DEFAULT_PASSWORD =
By default, don’t set a user password
nil- DEFAULT_CONNECTION_OPTIONS =
By default uses the Faraday connection options if none is set
{}
- DEFAULT_CONTENT_TYPE =
'application/json'.freeze
Constants included from Constants
Vertebrae::Constants::ACCEPT, Vertebrae::Constants::ACCEPT_CHARSET, Vertebrae::Constants::CACHE_CONTROL, Vertebrae::Constants::CONTENT_LENGTH, Vertebrae::Constants::CONTENT_TYPE, Vertebrae::Constants::DATE, Vertebrae::Constants::ETAG, Vertebrae::Constants::LOCATION, Vertebrae::Constants::RATELIMIT_LIMIT, Vertebrae::Constants::RATELIMIT_REMAINING, Vertebrae::Constants::SERVER, Vertebrae::Constants::USER_AGENT
Instance Attribute Summary collapse
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #endpoint ⇒ Object
- #faraday_options ⇒ Object
-
#initialize(options) ⇒ Configuration
constructor
A new instance of Configuration.
-
#process_basic_auth(auth) ⇒ Object
Extract login and password from basic_auth parameter.
Methods included from Authorization
#authenticated?, #authentication, #basic_auth, #password?, #username?
Constructor Details
#initialize(options) ⇒ Configuration
Returns a new instance of Configuration.
69 70 71 72 73 74 75 76 |
# File 'lib/configuration.rb', line 69 def initialize() self. = self. = {} VALID_OPTIONS_KEYS.each do |key| [key] = "Vertebrae::Configuration::DEFAULT_#{key.to_s.upcase}".constantize end end |
Instance Attribute Details
#default_options ⇒ Object
Returns the value of attribute default_options.
67 68 69 |
# File 'lib/configuration.rb', line 67 def @default_options end |
#options ⇒ Object
Returns the value of attribute options.
66 67 68 |
# File 'lib/configuration.rb', line 66 def @options end |
Instance Method Details
#endpoint ⇒ Object
106 107 108 |
# File 'lib/configuration.rb', line 106 def endpoint "https://#{self.host}#{self.prefix}" end |
#faraday_options ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/configuration.rb', line 79 def { :headers => { ACCEPT => "application/json;q=0.1", ACCEPT_CHARSET => "utf-8", USER_AGENT => user_agent, CONTENT_TYPE => content_type }, :ssl => ssl, :url => endpoint } end |
#process_basic_auth(auth) ⇒ Object
Extract login and password from basic_auth parameter
95 96 97 98 99 100 101 102 103 |
# File 'lib/configuration.rb', line 95 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 |