Parent

Class/Module Index [+]

Quicksearch

ActiveSupport::FileUpdateChecker

This class is responsible to track files and invoke the given block whenever one of these files are changed. For example, 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

Attributes

last_update_at[R]
paths[R]

Public Class Methods

new(paths, calculate=false, &block) click to toggle source
# File lib/active_support/file_update_checker.rb, line 18
def initialize(paths, calculate=false, &block)
  @paths = paths
  @block = block
  @last_update_at = calculate ? updated_at : nil
end

Public Instance Methods

execute_if_updated() click to toggle source
# File lib/active_support/file_update_checker.rb, line 28
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
updated_at() click to toggle source
# File lib/active_support/file_update_checker.rb, line 24
def updated_at
  paths.map { |path| File.stat(path).mtime }.max
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.