Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimizelyClient validity check fixed #289

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/optimizely/optimizely_user_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ def decide_all(options = nil)
# @return - true if the forced decision has been set successfully.

def set_forced_decision(context, decision)
return false unless @optimizely_client&.is_valid

flag_key = context[:flag_key]
return false if @optimizely_client&.get_optimizely_config.nil?
return false if flag_key.nil?

@forced_decision_mutex.synchronize { @forced_decisions[context] = decision }
Expand All @@ -126,7 +127,7 @@ def find_forced_decision(context)
# @return - A variation key or nil if forced decisions are not set for the parameters.

def get_forced_decision(context)
return nil if @optimizely_client&.get_optimizely_config.nil?
return nil unless @optimizely_client&.is_valid

find_forced_decision(context)
end
Expand All @@ -138,7 +139,7 @@ def get_forced_decision(context)
# @return - true if the forced decision has been removed successfully.

def remove_forced_decision(context)
return false if @optimizely_client&.get_optimizely_config.nil?
return false unless @optimizely_client&.is_valid

deleted = false
@forced_decision_mutex.synchronize do
Expand All @@ -155,7 +156,7 @@ def remove_forced_decision(context)
# @return - true if forced decisions have been removed successfully.

def remove_all_forced_decision
return false if @optimizely_client&.get_optimizely_config.nil?
return false unless @optimizely_client&.is_valid

@forced_decision_mutex.synchronize { @forced_decisions.clear }
true
Expand Down