Class: ActiveRecord::Materialized::RefreshScheduler Private
- Inherits:
-
Object
- Object
- ActiveRecord::Materialized::RefreshScheduler
- Defined in:
- lib/activerecord/materialized/refresh_scheduler.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.
Dispatches a view's configured refresh strategy (:async / :immediate / :manual) after a write.
Constant Summary collapse
- STRATEGIES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The refresh strategies a view may declare; the single source of truth shared by the
refresh_on_changeDSL (fail-fast validation) and this dispatcher. %i[async immediate manual].freeze
Class Method Summary collapse
- .schedule(view_class) ⇒ Object private
Class Method Details
.schedule(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.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/activerecord/materialized/refresh_scheduler.rb', line 14 def schedule(view_class) # Capture the transition before marking dirty so the async dispatcher # can coalesce: a bulk write only needs one job for the whole burst. newly_dirty = !view_class.dirty? view_class.mark_dependencies_changed! case view_class.resolved_refresh_strategy when :manual nil when :immediate view_class.refresh! when :async dispatch_async(view_class, newly_dirty) else raise ArgumentError, "Unknown refresh strategy: #{view_class.resolved_refresh_strategy}" end end |