instance method
max_mtime
Ruby on Rails 7.2.3
Since v4.0.13 PrivateSignature
max_mtime(paths)
This method returns the maximum mtime of the files in paths, or nil if the array is empty.
Files with a mtime in the future are ignored. Such abnormal situation can happen for example if the user changes the clock by hand. It is healthy to consider this edge case because with mtimes in the future reloading is not triggered.
Parameters
-
pathsreq
Source
# File activesupport/lib/active_support/file_update_checker.rb, line 122
def max_mtime(paths)
time_now = Time.at(0, Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond), :nanosecond)
max_mtime = nil
# Time comparisons are performed with #compare_without_coercion because
# AS redefines these operators in a way that is much slower and does not
# bring any benefit in this particular code.
#
# Read t1.compare_without_coercion(t2) < 0 as t1 < t2.
paths.each do |path|
mtime = File.mtime(path)
next if time_now.compare_without_coercion(mtime) < 0
if max_mtime.nil? || max_mtime.compare_without_coercion(mtime) < 0
max_mtime = mtime
end
end
max_mtime
end
Defined in activesupport/lib/active_support/file_update_checker.rb line 122
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::FileUpdateChecker