module

Rules::Maintainer

The generic maintainer: one algorithm that keeps every view's stored rows equal to its membership query.

Writes are raw SQL (bypassing the ORM) and wrapped in a transaction, so a collection is never observably a transient superset of its query.

Constants

Notifications produced imperatively. The batch reconcile leaves these untouched.

Log = ::Log.for(self)

Instance methods

bucket(type : String) : Symbol

Classifies a relationship type by who maintains it, partitioning the maintained-collection space so the batch reconcile never destroys a row it does not own:

  • :registry -- a registered view; the batch reconcile owns it.
  • :imperative -- a producer-written event record; left untouched.
  • :error -- neither.
Source
reconcile(view : View) : Bool

Rebuilds a view's stored rows to exactly equal its membership query.

Returns true if any rows changed, false otherwise.

Source
reconcile_for(view : View, key : View::Key) : Bool

Re-evaluates one key to an insert, delete, reposition, or no-op.

Fired after a base fact changes. Returns true if any rows changed, false otherwise.

Source
reconcile_object(object_iri : String) : Array(Tuple(View, String))

Re-evaluates every registered view for a changed object, projecting the object to each view's affected key(s).

Returns the (view, owner) pairs that changed.

Source
reconcile_object_for(view : View, object_iri : String) : Array(Tuple(View, String))

Re-evaluates a single view for a changed object, projecting the object to that view's affected key(s).

Returns the (view, owner) pairs that changed.

Source