Class: Audioproxy::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/audioproxy/config.rb

Overview

Process-global settings for URL generation. Assign through Audioproxy.configure; every attribute validates at assignment so a typo fails at boot rather than in a mailer.

Constant Summary collapse

HEX =
/\A(?:\h\h)+\z/
EXPIRY_KEYS =

Option keys defaults may carry: the proxy's typed short keys and their spelled-out aliases, plus the pre-rendered raw: escape hatch. An unrecognized key is a typo, and a typo that is silently dropped emits a valid URL for the wrong variant.

exp is subtracted deliberately (D1). It is an absolute instant, so a default would expire every URL the process ever mints at one second, and it would skip the validation the keywords run. expires_in below is the default that makes sense.

(Options::REQUEST_KEYS + Options::REQUEST_KEYS.filter_map { |key| Options::ALIASES[key] })
.uniq.freeze
OPTION_KEYS =
(([ :raw ] + Options::KEYS + Options::ALIASES.values).uniq - EXPIRY_KEYS).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



34
35
36
37
38
39
40
41
# File 'lib/audioproxy/config.rb', line 34

def initialize
  @endpoint = nil
  @key = nil
  @salt = nil
  @unsigned = false
  @default_options = {}
  @expires_in = nil
end

Instance Attribute Details

#default_optionsObject

Returns the value of attribute default_options.



31
32
33
# File 'lib/audioproxy/config.rb', line 31

def default_options
  @default_options
end

#endpointObject

Returns the value of attribute endpoint.



31
32
33
# File 'lib/audioproxy/config.rb', line 31

def endpoint
  @endpoint
end

#expires_inObject

Returns the value of attribute expires_in.



31
32
33
# File 'lib/audioproxy/config.rb', line 31

def expires_in
  @expires_in
end

#keyObject

Returns the value of attribute key.



31
32
33
# File 'lib/audioproxy/config.rb', line 31

def key
  @key
end

#saltObject

Returns the value of attribute salt.



31
32
33
# File 'lib/audioproxy/config.rb', line 31

def salt
  @salt
end

#unsignedObject

Returns the value of attribute unsigned.



32
33
34
# File 'lib/audioproxy/config.rb', line 32

def unsigned
  @unsigned
end