class ActiveSupport::FileUpdateChecker
end
i18n_reloader.execute_if_updated
ActionDispatch::Callbacks.to_prepare do
end
I18n.reload!
i18n_reloader = ActiveSupport::FileUpdateChecker.new(paths) do
changed upon a new request.
is used by Rails to reload the I18n framework whenever they are
whenever one of these files are changed. For example, this class
This class is responsible to track files and invoke the given block
def execute_if_updated
def execute_if_updated current_update_at = self.updated_at if @last_update_at != current_update_at @last_update_at = current_update_at @block.call end end
def initialize(paths, calculate=false, &block)
def initialize(paths, calculate=false, &block) @paths = paths @block = block @last_update_at = calculate ? updated_at : nil end
def updated_at
def updated_at paths.map { |path| File.stat(path).mtime }.max end