Module: Poly::Stack

Extended by:
ActiveSupport::Concern
Includes:
Role
Defined in:
lib/poly/stack.rb

Overview

Card-side concern. Turns a polymorphic, role-discriminated model (the "card" model, e.g. Status) into an append-only stack where the most-recently created card per (resource, role) is the current "prime" — the top of the stack.

class Status < ApplicationRecord
belongs_to :resource, polymorphic: true
include Poly::Joins
include Poly::Stack
poly_stack :resource
end

Poly::Stack builds on Poly::Role (the resource_role discriminator) and adds only is_prime (the enforced golden-child marker) and superseded_by_id (an unconstrained audit edge). It is deliberately payload agnostic: it does not define the payload column, the actor, or the reason — those belong to the host model. The parent-side accessor macro (has_stack) is the consumer's to write, the way Midas writes has_coin on Poly::Role — see the README.