class ActionView::CacheExpiry::ViewModificationWatcher

Public Class Methods

new(watcher:, &block) click to toggle source
# File lib/action_view/cache_expiry.rb, line 32
def initialize(watcher:, &block)
  @watched_dirs = nil
  @watcher_class = watcher
  @watcher = nil
  @mutex = Mutex.new
  @block = block
end

Public Instance Methods

execute_if_updated() click to toggle source
# File lib/action_view/cache_expiry.rb, line 40
def execute_if_updated
  @mutex.synchronize do
    watched_dirs = dirs_to_watch
    return if watched_dirs.empty?

    if watched_dirs != @watched_dirs
      @watched_dirs = watched_dirs
      @watcher = @watcher_class.new([], watched_dirs, &@block)
      @watcher.execute
    else
      @watcher.execute_if_updated
    end
  end
end

Private Instance Methods

all_view_paths() click to toggle source
# File lib/action_view/cache_expiry.rb, line 60
def all_view_paths
  ActionView::ViewPaths.all_view_paths.flat_map(&:paths)
end
dirs_to_watch() click to toggle source
# File lib/action_view/cache_expiry.rb, line 56
def dirs_to_watch
  all_view_paths.grep(FileSystemResolver).map!(&:path).tap(&:uniq!).sort!
end