Class: ActiveRecord::Materialized::Refresher Private
- Inherits:
-
Object
- Object
- ActiveRecord::Materialized::Refresher
- Defined in:
- lib/activerecord/materialized/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.
Orchestrates explicit rebuilds and incremental maintenance for a single view.
Defined Under Namespace
Classes: AlreadyRefreshingError, RefreshError
Instance Attribute Summary collapse
- #view_class ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(view_class) ⇒ Refresher
constructor
private
A new instance of Refresher.
-
#rebuild! ⇒ Object
private
Full materialization — the only path that scans all base data.
-
#refresh! ⇒ Object
private
Incremental maintenance only; a no-op when the view is not maintainable.
Constructor Details
#initialize(view_class) ⇒ Refresher
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.
Returns a new instance of Refresher.
21 22 23 24 |
# File 'lib/activerecord/materialized/refresher.rb', line 21 def initialize(view_class) @view_class = view_class @metadata = nil end |
Instance Attribute Details
#view_class ⇒ Object (readonly)
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 |
# File 'lib/activerecord/materialized/refresher.rb', line 19 def view_class @view_class end |
Instance Method Details
#rebuild! ⇒ 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.
Full materialization — the only path that scans all base data.
27 28 29 30 31 32 33 34 |
# File 'lib/activerecord/materialized/refresher.rb', line 27 def rebuild! guarded_maintenance do Instrumentation.refresh(view_class, operation: :rebuild) do |payload| payload[:mode] = :full run_cycle(-> { perform_rebuild! }) end end end |
#refresh! ⇒ 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.
Incremental maintenance only; a no-op when the view is not maintainable.
37 38 39 40 41 42 43 44 45 |
# File 'lib/activerecord/materialized/refresher.rb', line 37 def refresh! guarded_maintenance do Instrumentation.refresh(view_class, operation: :incremental) do |payload| next RefreshResult.skipped(view_class) unless maintainable? run_cycle(-> { IncrementalRefresh.new(view_class, payload).call }) end end end |