Class: ActionView::CacheExpiry::ViewModificationWatcher
- Inherits:
-
Object
- Object
- ActionView::CacheExpiry::ViewModificationWatcher
- Defined in:
- lib/action_view/cache_expiry.rb
Instance Method Summary collapse
- #execute_if_updated ⇒ Object
-
#initialize(watcher:, &block) ⇒ ViewModificationWatcher
constructor
A new instance of ViewModificationWatcher.
Constructor Details
#initialize(watcher:, &block) ⇒ ViewModificationWatcher
Returns a new instance of ViewModificationWatcher.
33 34 35 36 37 38 39 |
# File 'lib/action_view/cache_expiry.rb', line 33 def initialize(watcher:, &block) @watched_dirs = nil @watcher_class = watcher @watcher = nil @mutex = Mutex.new @block = block end |
Instance Method Details
#execute_if_updated ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/action_view/cache_expiry.rb', line 41 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 |