Class: ActiveRecord::Materialized::Registry Private
- Inherits:
-
Object
- Object
- ActiveRecord::Materialized::Registry
- Defined in:
- lib/activerecord/materialized/registry.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.
Tracks every defined view class and provides bulk operations (refresh / rebuild / warm-up / verify) across all of them.
Class Method Summary collapse
- .all ⇒ Object private
- .find(key) ⇒ Object private
- .for_class_name(class_name) ⇒ Object private
- .rebuild_all! ⇒ Object private
- .reconcile_all!(mode: :checksum, sample: nil) ⇒ Object private
- .reconcile_stale!(mode: :checksum, sample: nil) ⇒ Object private
-
.refresh_all! ⇒ Object
private
Incremental pass over every registered view; rebuild_all! for a full one.
- .refresh_stale! ⇒ Object private
- .register(view_class) ⇒ Object private
- .reset! ⇒ Object private
-
.stale_views ⇒ Object
private
Registered views that need maintenance — dirty, never refreshed, or past max_staleness.
- .unregister(view_class) ⇒ Object private
- .warm_up_all! ⇒ Object private
Class Method Details
.all ⇒ 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.
27 28 29 |
# File 'lib/activerecord/materialized/registry.rb', line 27 def all views.values end |
.find(key) ⇒ 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 |
# File 'lib/activerecord/materialized/registry.rb', line 19 def find(key) views[key.to_s] end |
.for_class_name(class_name) ⇒ 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.
23 24 25 |
# File 'lib/activerecord/materialized/registry.rb', line 23 def for_class_name(class_name) all.find { |view| view.name == class_name } end |
.rebuild_all! ⇒ 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.
47 48 49 |
# File 'lib/activerecord/materialized/registry.rb', line 47 def rebuild_all! all.map { |view| view.rebuild!(confirm: true) } end |
.reconcile_all!(mode: :checksum, sample: nil) ⇒ 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.
51 52 53 |
# File 'lib/activerecord/materialized/registry.rb', line 51 def reconcile_all!(mode: :checksum, sample: nil) all.map { |view| reconcile_view(view, mode: mode, sample: sample) } end |
.reconcile_stale!(mode: :checksum, sample: nil) ⇒ 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.
55 56 57 |
# File 'lib/activerecord/materialized/registry.rb', line 55 def reconcile_stale!(mode: :checksum, sample: nil) stale_views.map { |view| reconcile_view(view, mode: mode, sample: sample) } end |
.refresh_all! ⇒ 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 pass over every registered view; rebuild_all! for a full one.
32 33 34 |
# File 'lib/activerecord/materialized/registry.rb', line 32 def refresh_all! all.map(&:refresh!) end |
.refresh_stale! ⇒ 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.
43 44 45 |
# File 'lib/activerecord/materialized/registry.rb', line 43 def refresh_stale! stale_views.map(&:refresh!) end |
.register(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.
11 12 13 |
# File 'lib/activerecord/materialized/registry.rb', line 11 def register(view_class) views[view_class.view_key] = view_class 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.
63 64 65 |
# File 'lib/activerecord/materialized/registry.rb', line 63 def reset! @views = {} end |
.stale_views ⇒ 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.
Registered views that need maintenance — dirty, never refreshed, or past max_staleness. The single stale-view selection shared by the periodic refresh/reconcile paths, their rake tasks, and the job fan-out (ActiveRecord::Materialized.enqueue_stale_*!).
39 40 41 |
# File 'lib/activerecord/materialized/registry.rb', line 39 def stale_views all.select(&:stale?) end |
.unregister(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.
15 16 17 |
# File 'lib/activerecord/materialized/registry.rb', line 15 def unregister(view_class) views.delete(view_class.view_key) end |
.warm_up_all! ⇒ 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.
59 60 61 |
# File 'lib/activerecord/materialized/registry.rb', line 59 def warm_up_all! all.map(&:warm_up!) end |