Skip to content

Commit

Permalink
Simplify check for empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlogic committed Oct 19, 2024
1 parent 2c6762d commit 4e66243
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions judoscale-ruby/lib/judoscale/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ def as_json
end
end

BLANK_REGEXP = /\A[[:space:]]*\z/

private_constant :BLANK_REGEXP

include Singleton

@adapter_configs = []
Expand Down Expand Up @@ -114,7 +110,7 @@ def reset
end

def log_level=(new_level)
@log_level = blank_log_level?(new_level) ? nil : get_severity_log_level(new_level)
@log_level = get_severity_log_level(new_level)
end

def as_json
Expand All @@ -134,11 +130,9 @@ def ignore_large_requests?

private

def blank_log_level?(log_level)
log_level.nil? || log_level.match?(BLANK_REGEXP)
end

def get_severity_log_level(log_level)
return nil if log_level.to_s.strip.empty?

upcased_log_level = log_level.to_s.upcase

if ::Logger::Severity.const_defined?(upcased_log_level)
Expand Down

0 comments on commit 4e66243

Please sign in to comment.