Class: ActiveRecord::Materialized::Refresher Private

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
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: RefreshError

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



19
20
21
22
# File 'lib/activerecord/materialized/refresher.rb', line 19

def initialize(view_class)
  @view_class = view_class
  @metadata = T.let(nil, T.nilable(Metadata))
end

Instance Attribute Details

#view_classObject (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.



16
17
18
# File 'lib/activerecord/materialized/refresher.rb', line 16

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.



26
27
28
29
30
# File 'lib/activerecord/materialized/refresher.rb', line 26

def rebuild!
  run_cycle(-> { perform_rebuild! })
rescue StandardError => e
  fail_refresh!(e)
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.



34
35
36
37
38
39
40
# File 'lib/activerecord/materialized/refresher.rb', line 34

def refresh!
  return RefreshResult.skipped(view_class) unless maintainable?

  run_cycle(-> { incremental_refresh! })
rescue StandardError => e
  fail_refresh!(e)
end