Class: Optimizely::StaticProjectConfigManager

Inherits:
ProjectConfigManager show all
Defined in:
lib/optimizely/config_manager/static_project_config_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datafile, logger, error_handler, skip_json_validation) ⇒ StaticProjectConfigManager

Returns a new instance of StaticProjectConfigManager.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/optimizely/config_manager/static_project_config_manager.rb', line 28

def initialize(datafile, logger, error_handler, skip_json_validation)
  # Looks up and sets datafile and config based on response body.
  #
  # datafile - JSON string representing the Optimizely project.
  # logger - Provides a logger instance.
  # error_handler - Provides a handle_error method to handle exceptions.
  # skip_json_validation - Optional boolean param which allows skipping JSON schema
  #                       validation upon object invocation. By default JSON schema validation will be performed.
  # Returns instance of DatafileProjectConfig, nil otherwise.
  super()
  @config = DatafileProjectConfig.create(
    datafile,
    logger,
    error_handler,
    skip_json_validation
  )
  @logger = logger
  @sdk_key = @config&.sdk_key
  @optimizely_config = nil
end

Instance Attribute Details

#configObject (readonly)

Implementation of ProjectConfigManager interface.



26
27
28
# File 'lib/optimizely/config_manager/static_project_config_manager.rb', line 26

def config
  @config
end

#sdk_keyObject (readonly)

Implementation of ProjectConfigManager interface.



26
27
28
# File 'lib/optimizely/config_manager/static_project_config_manager.rb', line 26

def sdk_key
  @sdk_key
end

Instance Method Details

#optimizely_configObject



49
50
51
52
53
# File 'lib/optimizely/config_manager/static_project_config_manager.rb', line 49

def optimizely_config
  @optimizely_config = OptimizelyConfig.new(@config, @logger).config if @optimizely_config.nil?

  @optimizely_config
end