Class: ActionView::CacheExpiry
- Inherits:
-
Object
- Object
- ActionView::CacheExpiry
- Defined in:
- lib/action_view/cache_expiry.rb
Defined Under Namespace
Classes: Executor
Instance Method Summary collapse
- #clear_cache ⇒ Object
- #clear_cache_if_necessary ⇒ Object
-
#initialize(watcher:) ⇒ CacheExpiry
constructor
A new instance of CacheExpiry.
Constructor Details
#initialize(watcher:) ⇒ CacheExpiry
Returns a new instance of CacheExpiry.
15 16 17 18 19 20 |
# File 'lib/action_view/cache_expiry.rb', line 15 def initialize(watcher:) @watched_dirs = nil @watcher_class = watcher @watcher = nil @mutex = Mutex.new end |
Instance Method Details
#clear_cache ⇒ Object
39 40 41 |
# File 'lib/action_view/cache_expiry.rb', line 39 def clear_cache ActionView::LookupContext::DetailsKey.clear end |
#clear_cache_if_necessary ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |