Skip to content

Commit 6c357e9

Browse files
committed
Update shims for older rubies
`Symbol#name` and `Time#floor` are now present on the minimum required version.
1 parent 1702b6c commit 6c357e9

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

activesupport/lib/active_support/core_ext/range/overlap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Range
44
# Compare two ranges and see if they overlap each other
55
# (1..5).overlap?(4..6) # => true
66
# (1..5).overlap?(7..9) # => false
7-
unless Range.method_defined?(:overlap?)
7+
unless Range.method_defined?(:overlap?) # Ruby 3.3+
88
def overlap?(other)
99
raise TypeError unless other.is_a? Range
1010

activesupport/lib/active_support/core_ext/time/calculations.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ def sec_fraction
108108
subsec
109109
end
110110

111-
unless Time.method_defined?(:floor)
112-
def floor(precision = 0)
113-
change(nsec: 0) + subsec.floor(precision)
114-
end
115-
end
116-
117111
# Returns a new Time where one or more of the elements have been changed according
118112
# to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>,
119113
# <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly, so if only

activesupport/lib/active_support/hash_with_indifferent_access.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,8 @@ def to_proc
392392
end
393393

394394
private
395-
if Symbol.method_defined?(:name)
396-
def convert_key(key)
397-
key.kind_of?(Symbol) ? key.name : key
398-
end
399-
else
400-
def convert_key(key)
401-
key.kind_of?(Symbol) ? key.to_s : key
402-
end
395+
def convert_key(key)
396+
key.kind_of?(Symbol) ? key.name : key
403397
end
404398

405399
def convert_value(value, conversion: nil)

railties/lib/rails/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def initialize(message, name, alternatives)
2323
super(message)
2424
end
2525

26-
if !Exception.method_defined?(:detailed_message)
26+
if !Exception.method_defined?(:detailed_message) # Ruby 3.2+
2727
def detailed_message(...)
2828
message
2929
end

0 commit comments

Comments
 (0)