Merge pull request #50602 from Shopify/symbol-name-cleanup

Update shims for older rubies
This commit is contained in:
Jean Boussier 2024-01-05 17:22:23 +01:00 committed by GitHub
commit 21090a1319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 16 deletions

View File

@ -4,7 +4,7 @@ class Range
# Compare two ranges and see if they overlap each other
# (1..5).overlap?(4..6) # => true
# (1..5).overlap?(7..9) # => false
unless Range.method_defined?(:overlap?)
unless Range.method_defined?(:overlap?) # Ruby 3.3+
def overlap?(other)
raise TypeError unless other.is_a? Range

View File

@ -108,12 +108,6 @@ class Time
subsec
end
unless Time.method_defined?(:floor)
def floor(precision = 0)
change(nsec: 0) + subsec.floor(precision)
end
end
# Returns a new Time where one or more of the elements have been changed according
# to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>,
# <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly, so if only

View File

@ -392,14 +392,8 @@ module ActiveSupport
end
private
if Symbol.method_defined?(:name)
def convert_key(key)
key.kind_of?(Symbol) ? key.name : key
end
else
def convert_key(key)
key.kind_of?(Symbol) ? key.to_s : key
end
def convert_key(key)
key.kind_of?(Symbol) ? key.name : key
end
def convert_value(value, conversion: nil)

View File

@ -23,7 +23,7 @@ module Rails
super(message)
end
if !Exception.method_defined?(:detailed_message)
if !Exception.method_defined?(:detailed_message) # Ruby 3.2+
def detailed_message(...)
message
end