Class: Quovo::Config

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

Constant Summary collapse

DEFAULT_ENDPOINT =
'https://api.quovo.com/v2'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



14
15
16
17
18
19
20
21
22
23
# File 'lib/quovo/config.rb', line 14

def initialize
  @username               = nil
  @password               = nil
  @token_ttl              = 60 * 60
  @request_timeout        = 60
  @token_prefix           = 'QUOVO-ACCESS-TOKEN'
  @token_storage          = default_memory_storage
  @debug                  = false
  @strip_sensitive_params = true
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



9
10
11
# File 'lib/quovo/config.rb', line 9

def debug
  @debug
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/quovo/config.rb', line 4

def password
  @password
end

#request_timeoutObject

seconds



6
7
8
# File 'lib/quovo/config.rb', line 6

def request_timeout
  @request_timeout
end

#strip_sensitive_paramsObject

Returns the value of attribute strip_sensitive_params.



10
11
12
# File 'lib/quovo/config.rb', line 10

def strip_sensitive_params
  @strip_sensitive_params
end

#token_prefixObject

Returns the value of attribute token_prefix.



7
8
9
# File 'lib/quovo/config.rb', line 7

def token_prefix
  @token_prefix
end

#token_storageObject

Returns the value of attribute token_storage.



8
9
10
# File 'lib/quovo/config.rb', line 8

def token_storage
  @token_storage
end

#token_ttlObject

seconds



5
6
7
# File 'lib/quovo/config.rb', line 5

def token_ttl
  @token_ttl
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/quovo/config.rb', line 3

def username
  @username
end

Class Method Details

.configuratorObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/quovo/config.rb', line 33

def self.configurator
  @conf_mod ||= Module.new do
    def configure
      yield(config)
    end

    def config
      @config ||= Config.new
    end
  end
end

Instance Method Details

#[](option) ⇒ Object



29
30
31
# File 'lib/quovo/config.rb', line 29

def [](option)
  send(option)
end

#default_memory_storageObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/quovo/config.rb', line 45

def default_memory_storage
  Object.new.tap do |o|
    def o.storage
      @storage ||= {}
    end

    def o.read(key)
      storage[key]
    end

    def o.write(key, value)
      storage[key] = value
    end
  end
end

#endpointObject



25
26
27
# File 'lib/quovo/config.rb', line 25

def endpoint
  DEFAULT_ENDPOINT
end