Class: Kameleoon::ClientConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/kameleoon/client_config.rb

Overview

Client configuration which can be used instead of an external configuration file

Constant Summary collapse

CONFIGURATION_UPDATE_INTERVAL =
60
VISITOR_DATA_MAXIMUM_SIZE =
500
DEFAULT_TIMEOUT =

milli-seconds

2000

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id: nil, client_secret: nil, configuration_refresh_interval: CONFIGURATION_UPDATE_INTERVAL, default_timeout: DEFAULT_TIMEOUT, visitor_data_maximum_size: VISITOR_DATA_MAXIMUM_SIZE, environment: nil, verbose_mode: false) ⇒ ClientConfig

Returns a new instance of ClientConfig.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kameleoon/client_config.rb', line 13

def initialize(
  client_id: nil,
  client_secret: nil,
  configuration_refresh_interval: CONFIGURATION_UPDATE_INTERVAL,
  default_timeout: DEFAULT_TIMEOUT,
  visitor_data_maximum_size: VISITOR_DATA_MAXIMUM_SIZE,
  environment: nil,
  verbose_mode: false
)
  @client_id = client_id
  @client_secret = client_secret
  @configuration_refresh_interval = configuration_refresh_interval || CONFIGURATION_UPDATE_INTERVAL
  @default_timeout = default_timeout || DEFAULT_TIMEOUT
  @visitor_data_maximum_size = visitor_data_maximum_size || VISITOR_DATA_MAXIMUM_SIZE
  @environment = environment
  @verbose_mode = verbose_mode || false
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



10
11
12
# File 'lib/kameleoon/client_config.rb', line 10

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



10
11
12
# File 'lib/kameleoon/client_config.rb', line 10

def client_secret
  @client_secret
end

#configuration_refresh_intervalObject (readonly)

Returns the value of attribute configuration_refresh_interval.



10
11
12
# File 'lib/kameleoon/client_config.rb', line 10

def configuration_refresh_interval
  @configuration_refresh_interval
end

#data_refresh_intervalObject (readonly)

Returns the value of attribute data_refresh_interval.



10
11
12
# File 'lib/kameleoon/client_config.rb', line 10

def data_refresh_interval
  @data_refresh_interval
end

#default_timeoutObject (readonly)

Returns the value of attribute default_timeout.



10
11
12
# File 'lib/kameleoon/client_config.rb', line 10

def default_timeout
  @default_timeout
end

#environmentObject (readonly)

Returns the value of attribute environment.



10
11
12
# File 'lib/kameleoon/client_config.rb', line 10

def environment
  @environment
end

#verbose_modeObject (readonly)

Returns the value of attribute verbose_mode.



10
11
12
# File 'lib/kameleoon/client_config.rb', line 10

def verbose_mode
  @verbose_mode
end

#visitor_data_maximum_sizeObject (readonly)

Returns the value of attribute visitor_data_maximum_size.



10
11
12
# File 'lib/kameleoon/client_config.rb', line 10

def visitor_data_maximum_size
  @visitor_data_maximum_size
end

Class Method Details

.make_from_yaml(yaml) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/kameleoon/client_config.rb', line 31

def self.make_from_yaml(yaml)
  yaml ||= {}
  ClientConfig.new(
    client_id: yaml['client_id'],
    client_secret: yaml['client_secret'],
    configuration_refresh_interval: yaml['actions_configuration_refresh_interval'],
    default_timeout: yaml['default_timeout'],
    visitor_data_maximum_size: yaml['visitor_data_maximum_size'],
    environment: yaml['environment'],
    verbose_mode: yaml['verbose_mode']
  )
end