Class: ActionView::CacheExpiry::ViewReloader

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/cache_expiry.rb

Instance Method Summary collapse

Constructor Details

#initialize(watcher:, &block) ⇒ ViewReloader

Returns a new instance of ViewReloader.



6
7
8
9
10
11
12
13
14
# File 'lib/action_view/cache_expiry.rb', line 6

def initialize(watcher:, &block)
  @mutex = Mutex.new
  @watcher_class = watcher
  @watched_dirs = nil
  @watcher = nil
  @previous_change = false

  ActionView::PathRegistry.file_system_resolver_hooks << method(:rebuild_watcher)
end

Instance Method Details

#executeObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/action_view/cache_expiry.rb', line 21

def execute
  return unless @watcher

  watcher = nil
  @mutex.synchronize do
    @previous_change = false
    watcher = @watcher
  end
  watcher.execute
end

#updated?Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/action_view/cache_expiry.rb', line 16

def updated?
  build_watcher unless @watcher
  @previous_change || @watcher.updated?
end