Class: Optimizely::OdpConfig
- Inherits:
-
Object
- Object
- Optimizely::OdpConfig
- Defined in:
- lib/optimizely/odp/odp_config.rb
Constant Summary collapse
- ODP_CONFIG_STATE =
Helpers::Constants::ODP_CONFIG_STATE
Instance Method Summary collapse
-
#api_host ⇒ Object
Returns the api host for odp connections.
-
#api_key ⇒ Object
Returns the api key for odp connections.
-
#initialize(api_key = nil, api_host = nil, segments_to_check = []) ⇒ OdpConfig
constructor
Contains configuration used for ODP integration.
-
#odp_state ⇒ Object
Returns the state of odp integration (UNDETERMINED, INTEGRATED, NOT_INTEGRATED).
-
#segments_to_check ⇒ Object
Returns An array of qualified segments for this user.
-
#segments_to_check=(segments_to_check) ⇒ Object
Replace qualified segments with provided segments.
-
#update(api_key = nil, api_host = nil, segments_to_check = []) ⇒ Object
Replaces the existing configuration.
Constructor Details
#initialize(api_key = nil, api_host = nil, segments_to_check = []) ⇒ OdpConfig
Contains configuration used for ODP integration.
30 31 32 33 34 35 36 |
# File 'lib/optimizely/odp/odp_config.rb', line 30 def initialize(api_key = nil, api_host = nil, segments_to_check = []) @api_key = api_key @api_host = api_host @segments_to_check = segments_to_check @mutex = Mutex.new @odp_state = @api_host.nil? || @api_key.nil? ? ODP_CONFIG_STATE[:UNDETERMINED] : ODP_CONFIG_STATE[:INTEGRATED] end |
Instance Method Details
#api_host ⇒ Object
Returns the api host for odp connections
66 67 68 |
# File 'lib/optimizely/odp/odp_config.rb', line 66 def api_host @mutex.synchronize { @api_host.clone } end |
#api_key ⇒ Object
Returns the api key for odp connections
74 75 76 |
# File 'lib/optimizely/odp/odp_config.rb', line 74 def api_key @mutex.synchronize { @api_key.clone } end |
#odp_state ⇒ Object
Returns the state of odp integration (UNDETERMINED, INTEGRATED, NOT_INTEGRATED)
98 99 100 |
# File 'lib/optimizely/odp/odp_config.rb', line 98 def odp_state @mutex.synchronize { @odp_state } end |
#segments_to_check ⇒ Object
Returns An array of qualified segments for this user
82 83 84 |
# File 'lib/optimizely/odp/odp_config.rb', line 82 def segments_to_check @mutex.synchronize { @segments_to_check.clone } end |
#segments_to_check=(segments_to_check) ⇒ Object
Replace qualified segments with provided segments
90 91 92 |
# File 'lib/optimizely/odp/odp_config.rb', line 90 def segments_to_check=(segments_to_check) @mutex.synchronize { @segments_to_check = segments_to_check.clone } end |
#update(api_key = nil, api_host = nil, segments_to_check = []) ⇒ Object
Replaces the existing configuration
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/optimizely/odp/odp_config.rb', line 46 def update(api_key = nil, api_host = nil, segments_to_check = []) updated = false @mutex.synchronize do @odp_state = api_host.nil? || api_key.nil? ? ODP_CONFIG_STATE[:NOT_INTEGRATED] : ODP_CONFIG_STATE[:INTEGRATED] if @api_key != api_key || @api_host != api_host || @segments_to_check != segments_to_check @api_key = api_key @api_host = api_host @segments_to_check = segments_to_check updated = true end end updated end |