Class: ActionView::CacheExpiry::ViewReloader

Inherits:
Object
  • Object
show all
Defined in:
actionview/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
15
16
# File 'actionview/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

  rebuild_watcher

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

Instance Method Details

#executeObject



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

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

#updated?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'actionview/lib/action_view/cache_expiry.rb', line 18

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