Parent

Class 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::Callbacks.to_prepare do
    i18n_reloader.execute_if_updated
  end

Attributes

paths[R]
last_update_at[R]

Public Class Methods

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

Public Instance Methods

execute_if_updated() click to toggle source
    # File lib/active_support/file_update_checker.rb, line 28
28:     def execute_if_updated
29:       current_update_at = self.updated_at
30:       if @last_update_at != current_update_at
31:         @last_update_at = current_update_at
32:         @block.call
33:       end
34:     end
updated_at() click to toggle source
    # File lib/active_support/file_update_checker.rb, line 24
24:     def updated_at
25:       paths.map { |path| File.stat(path).mtime }.max
26:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.