Skip to content

Commit

Permalink
fix(ruby): Fix some minor Ruby style issues (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecsl authored Jan 8, 2025
1 parent 6f360ed commit 3643641
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions ruby-sdk/lib/eppo_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Client
def init(config)
config.validate

if !@core.nil?
if @core
STDERR.puts "Eppo Warning: multiple initialization of the client"
@core.shutdown
end
Expand Down Expand Up @@ -91,7 +91,10 @@ def get_bandit_action(flag_key, subject_key, subject_attributes, actions, defaul
log_assignment(result[:assignment_event])
log_bandit_action(result[:bandit_event])

return {:variation => result[:variation], :action => result[:action]}
{
:variation => result[:variation],
:action => result[:action]
}
end

def get_bandit_action_details(flag_key, subject_key, subject_attributes, actions, default_variation)
Expand All @@ -102,7 +105,7 @@ def get_bandit_action_details(flag_key, subject_key, subject_attributes, actions
log_assignment(result[:assignment_event])
log_bandit_action(result[:bandit_event])

return {
{
:variation => result[:variation],
:action => result[:action],
:evaluationDetails => details
Expand All @@ -116,9 +119,7 @@ def get_assignment_inner(flag_key, subject_key, subject_attributes, expected_typ
logger = Logger.new($stdout)
begin
assignment = @core.get_assignment(flag_key, subject_key, subject_attributes, expected_type)
if not assignment then
return default_value
end
return default_value unless assignment

log_assignment(assignment[:event])

Expand All @@ -137,16 +138,16 @@ def get_assignment_details_inner(flag_key, subject_key, subject_attributes, expe
result, event = @core.get_assignment_details(flag_key, subject_key, subject_attributes, expected_type)
log_assignment(event)

if not result[:variation] then
if !result[:variation]
result[:variation] = default_value
end

return result
result
end
# rubocop:enable Metrics/MethodLength

def log_assignment(event)
if not event then return end
return unless event

# Because rust's AssignmentEvent has a #[flatten] extra_logging
# field, serde_magnus serializes it as a normal HashMap with
Expand All @@ -167,7 +168,7 @@ def log_assignment(event)
end

def log_bandit_action(event)
if not event then return end
return unless event

begin
@assignment_logger.log_bandit_action(event)
Expand Down

0 comments on commit 3643641

Please sign in to comment.