Type:
Class

FileUpdateChecker specifies the API used by Rails to watch files and control reloading. The API depends on four methods:

  • initialize which expects two parameters and one block as described below.

  • updated? which returns a boolean if there were updates in the filesystem or not.

  • execute which executes the given block on initialization and updates the latest watched files and timestamp.

  • execute_if_updated which just executes the block if it was updated.

After initialization, a call to execute_if_updated must execute the block only if there was really a change in the filesystem.

This class is used by Rails to reload the I18n framework whenever they are changed upon a new request.

i18n_reloader = ActiveSupport::FileUpdateChecker.new(paths) do
  I18n.reload!
end

ActionDispatch::Reloader.to_prepare do
  i18n_reloader.execute_if_updated
end
execute

execute() Instance Public methods Executes the given block and updates the latest

2015-06-20 00:00:00
updated?

updated?() Instance Public methods Check if any of the entries were updated

2015-06-20 00:00:00
execute_if_updated

execute_if_updated() Instance Public methods Execute the block given if updated

2015-06-20 00:00:00
new

new(files, dirs={}, &block) Class Public methods It accepts two parameters

2015-06-20 00:00:00