Class: ActiveRecord::Materialized::View
- Inherits:
-
Base
- Object
- Base
- ActiveRecord::Materialized::View
- Extended by:
- T::Sig
- Defined in:
- lib/activerecord/materialized/view.rb
Overview
The base class for an application-level materialized view. Subclass it, point ActiveRecord::Materialized::ViewConfigurationClassMethods::ClassMethods#materialized_from at an ‘ActiveRecord::Relation`, declare the models it depends_on, and then read it like any ActiveRecord model. Reads are served from a cache table the gem maintains incrementally as the underlying data changes; a full materialization happens only via an explicit rebuild!, and until then reads transparently fall through to the source query.
Class Attribute Summary collapse
-
.max_staleness_setting ⇒ Object
readonly
Returns the value of attribute max_staleness_setting.
-
.source_definition ⇒ Object
readonly
Returns the value of attribute source_definition.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from ViewQueryAccessClassMethods
Methods included from ViewConfigurationClassMethods
Methods included from RefreshCallbacks
Class Attribute Details
.max_staleness_setting ⇒ Object (readonly)
Returns the value of attribute max_staleness_setting.
63 64 65 |
# File 'lib/activerecord/materialized/view.rb', line 63 def max_staleness_setting @max_staleness_setting end |
.source_definition ⇒ Object (readonly)
Returns the value of attribute source_definition.
60 61 62 |
# File 'lib/activerecord/materialized/view.rb', line 60 def source_definition @source_definition end |
Class Method Details
.dependency_tables ⇒ Object
66 67 68 69 |
# File 'lib/activerecord/materialized/view.rb', line 66 def dependency_tables tables = T.let(T.unsafe(self).instance_variable_get(:@dependency_tables), T.nilable(T::Array[String])) tables.nil? ? [] : tables end |
Instance Method Details
#stale? ⇒ Boolean
73 74 75 76 |
# File 'lib/activerecord/materialized/view.rb', line 73 def stale? T.bind(self, View) self.class.stale? end |