class ActionView::CacheExpiry

Public Class Methods

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

Public Instance Methods

clear_cache() click to toggle source
# File lib/action_view/cache_expiry.rb, line 39
def clear_cache
  ActionView::LookupContext::DetailsKey.clear
end
clear_cache_if_necessary() click to toggle source
# File lib/action_view/cache_expiry.rb, line 22
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

Private Instance Methods

all_view_paths() click to toggle source
# File lib/action_view/cache_expiry.rb, line 48
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 44
def dirs_to_watch
  all_view_paths.grep(FileSystemResolver).map!(&:path).tap(&:uniq!).sort!
end