class Bearer::Configuration

stores global Bearer configuration options @see app.bearer.sh/settings @attr_writer [String] secret_key secret key from app.bearer.sh/settings @attr_writer [String] publishable_key publishable key from app.bearer.sh/settings @attr_writer [String] encryption_key encryption key from app.bearer.sh/settings @attr_writer [Hash] http_client_settings options passed as a parameters to Net::HTTP#start @attr_writer [String] host mainly used internally

Constants

ALL_METHODS
DEFAULT_INITIAL_NETWORK_RETRY_DELAY
DEFAULT_MAX_NETWORK_RETRIES
DEFAULT_MAX_NETWORK_RETRY_DELAY
DEFAULT_OPEN_TIMEOUT
DEFAULT_READ_TIMEOUT
DEPRECATED_FIELDS
EXISTING_METHODS
FIELDS
PRODUCTION_AUTH_HOST
PRODUCTION_INTEGRATION_HOST

Public Class Methods

method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/bearer/configuration.rb, line 179
def method_missing(name, *args, &block)
  super unless EXISTING_METHODS.include? name
  instance.public_send(name, *args, &block)
end
reset() click to toggle source
# File lib/bearer/configuration.rb, line 188
def reset
  FIELDS.each do |field|
    value = field == :log_level ? :info : nil
    instance.public_send("#{field}=", value)
  end
end
respond_to_missing?(name, include_private = false) click to toggle source
Calls superclass method
# File lib/bearer/configuration.rb, line 184
def respond_to_missing?(name, include_private = false)
  EXISTING_METHODS.include?(name) || super
end
setup() { |instance| ... } click to toggle source
# File lib/bearer/configuration.rb, line 195
def setup
  yield(instance)
end

Public Instance Methods

api_key() click to toggle source

@deprecated Use {#secret_key} instead. @return [String]

# File lib/bearer/configuration.rb, line 114
def api_key
  deprecate("api_key", "secret_key")
  secret_key
end
api_key=(value) click to toggle source

@deprecated Use {#secret_key=} instead. @return [void]

# File lib/bearer/configuration.rb, line 137
def api_key=(value)
  deprecate("api_key=", "secret_key=")
  @secret_key = value
end
auth_host() click to toggle source

@return [String]

# File lib/bearer/configuration.rb, line 61
def auth_host
  @auth_host ||= PRODUCTION_AUTH_HOST
end
client_id() click to toggle source

@deprecated Use {#publishable_key} instead. @return [String]

# File lib/bearer/configuration.rb, line 121
def client_id
  deprecate("client_id", "publishable_key")
  publishable_key
end
client_id=(value) click to toggle source

@deprecated Use {#publishable_key=} instead. @return [void]

# File lib/bearer/configuration.rb, line 144
def client_id=(value)
  deprecate("client_id=", "publishable_key=")
  @publishable_key = value
end
encryption_key() click to toggle source

@return [String]

# File lib/bearer/configuration.rb, line 108
def encryption_key
  raise_if_missing(:encryption_key)
end
host() click to toggle source

@return [String]

# File lib/bearer/configuration.rb, line 66
def host
  @host ||= PRODUCTION_INTEGRATION_HOST
end
http_client_params() click to toggle source

@deprecated use {#http_client_settings} instead @return [Hash<String,String>]

# File lib/bearer/configuration.rb, line 92
def http_client_params
  deprecate("http_client_params", "http_client_settings")
  http_client_settings
end
http_client_params=(value) click to toggle source

@deprecated Use {#http_client_settings=} instead. @return [void]

# File lib/bearer/configuration.rb, line 165
def http_client_params=(value)
  deprecate("http_client_params=", "http_client_settings=")
  @http_client_settings = value
end
http_client_settings() click to toggle source

@return [Hash]

# File lib/bearer/configuration.rb, line 86
def http_client_settings
  default_http_client_settings.merge(@http_client_settings || {})
end
initial_network_retry_delay() click to toggle source

@return [Float]

# File lib/bearer/configuration.rb, line 81
def initial_network_retry_delay
  @initial_network_retry_delay ||= DEFAULT_INITIAL_NETWORK_RETRY_DELAY
end
integration_host() click to toggle source

@return [String]

# File lib/bearer/configuration.rb, line 50
def integration_host
  deprecate("integration_host", "host")
  host
end
integration_host=(value) click to toggle source

@deprecated Use {#host=} instead. @return [void]

# File lib/bearer/configuration.rb, line 158
def integration_host=(value)
  deprecate("integration_host=", "host=")
  @host = value
end
log_level() click to toggle source

@return [Integer]

# File lib/bearer/configuration.rb, line 56
def log_level
  @log_level ||= :info
end
log_level=(severity) click to toggle source
# File lib/bearer/configuration.rb, line 170
def log_level=(severity)
  Bearer.logger.level = severity
  @log_level = severity
end
max_network_retries() click to toggle source

@return [Integer]

# File lib/bearer/configuration.rb, line 71
def max_network_retries
  @max_network_retries ||= DEFAULT_MAX_NETWORK_RETRIES
end
max_network_retry_delay() click to toggle source

@return [Float]

# File lib/bearer/configuration.rb, line 76
def max_network_retry_delay
  @max_network_retry_delay ||= DEFAULT_MAX_NETWORK_RETRY_DELAY
end
publishable_key() click to toggle source

@return [String]

# File lib/bearer/configuration.rb, line 103
def publishable_key
  raise_if_missing(:publishable_key)
end
secret() click to toggle source

@deprecated Use {#encryption_key} instead. @return [String]

# File lib/bearer/configuration.rb, line 128
def secret
  deprecate("secret", "encryption_key")
  encryption_key
end
secret=(value) click to toggle source

@deprecated Use {#encryption_key=} instead. @return [void]

# File lib/bearer/configuration.rb, line 151
def secret=(value)
  deprecate("secret=", "encryption_key=")
  @encryption_key = value
end
secret_key() click to toggle source

@return [String]

# File lib/bearer/configuration.rb, line 98
def secret_key
  raise_if_missing(:secret_key)
end

Private Instance Methods

default_http_client_settings() click to toggle source

@return [Hash]

# File lib/bearer/configuration.rb, line 227
def default_http_client_settings
  {
    read_timeout: read_timeout,
    open_timeout: open_timeout
  }
end
deprecate(old_field, new_field) click to toggle source
# File lib/bearer/configuration.rb, line 210
def deprecate(old_field, new_field)
  puts "Bearer Deprecation Warning: #{old_field} is deprecated, use #{new_field} instead"
end
open_timeout() click to toggle source

defaults to 5 seconds @return [Integer]

# File lib/bearer/configuration.rb, line 216
def open_timeout
  @open_timeout || DEFAULT_READ_TIMEOUT
end
raise_if_missing(field) click to toggle source
# File lib/bearer/configuration.rb, line 202
def raise_if_missing(field)
  value = instance_variable_get(:"@#{field}")

  raise ::Bearer::Errors::Configuration, "Bearer #{field} is missing!" unless value

  value
end
read_timeout() click to toggle source

defaults to 5 seconds @return [Integer]

# File lib/bearer/configuration.rb, line 222
def read_timeout
  @read_timeout || DEFAULT_READ_TIMEOUT
end