class ActionView::CacheExpiry

def all_view_paths

def all_view_paths
  ActionView::ViewPaths.all_view_paths.flat_map(&:paths)
end

def clear_cache

def clear_cache
  ActionView::LookupContext::DetailsKey.clear
end

def clear_cache_if_necessary

def clear_cache_if_necessary
  @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) do
        clear_cache
      end
      @watcher.execute
    else
      @watcher.execute_if_updated
    end
  end
end

def dirs_to_watch

def dirs_to_watch
  fs_paths = all_view_paths.grep(FileSystemResolver)
  fs_paths.map(&:path).sort.uniq
end

def initialize(watcher:)

def initialize(watcher:)
  @watched_dirs = nil
  @watcher_class = watcher
  @watcher = nil
  @mutex = Mutex.new
end