Class: ActiveRecord::Materialized::AsyncRefresher Private
- Inherits:
-
Object
- Object
- ActiveRecord::Materialized::AsyncRefresher
- Defined in:
- lib/activerecord/materialized/async_refresher.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
In-process, debounced background refresher — the default :async dispatcher.
Class Attribute Summary collapse
-
.paused ⇒ Object
writeonly
private
When paused, refreshes accumulate and run only on an explicit flush! — no background timer fires.
Class Method Summary collapse
- .enqueue(view_class) ⇒ Object private
- .flush! ⇒ Object private
- .paused? ⇒ Boolean private
- .pending_count ⇒ Object private
- .reset! ⇒ Object private
Class Attribute Details
.paused=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
When paused, refreshes accumulate and run only on an explicit flush! — no background timer fires.
39 40 41 |
# File 'lib/activerecord/materialized/async_refresher.rb', line 39 def paused=(value) @paused = value end |
Class Method Details
.enqueue(view_class) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 14 15 16 17 |
# File 'lib/activerecord/materialized/async_refresher.rb', line 10 def enqueue(view_class) interval = view_class.resolved_refresh_debounce mutex.synchronize do pending[view_class.view_key] = view_class schedule_unlocked(interval) end end |
.flush! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 |
# File 'lib/activerecord/materialized/async_refresher.rb', line 19 def flush! mutex.synchronize do cancel_timer_unlocked drain_pending_unlocked end end |
.paused? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'lib/activerecord/materialized/async_refresher.rb', line 41 def paused? @paused || false end |
.pending_count ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/activerecord/materialized/async_refresher.rb', line 26 def pending_count mutex.synchronize { pending.size } end |
.reset! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 |
# File 'lib/activerecord/materialized/async_refresher.rb', line 30 def reset! mutex.synchronize do cancel_timer_unlocked pending.clear end end |