[ruby/securerandom] Only define compatible method in < Ruby 3.3

https://github.com/ruby/securerandom/commit/2c8cdfba7b
This commit is contained in:
Hiroshi SHIBATA 2024-12-16 14:02:39 +09:00 committed by git
parent 3a4433dddd
commit 7923e420c4

View File

@ -53,13 +53,9 @@ module SecureRandom
# Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2 # Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
def alphanumeric(n = nil, chars: ALPHANUMERIC) def alphanumeric(n = nil, chars: ALPHANUMERIC)
if RUBY_VERSION < '3.3' n = 16 if n.nil?
n = 16 if n.nil? choose(chars, n)
choose(chars, n) end if RUBY_VERSION < '3.3'
else
super n, chars: chars
end
end
private private