Module: Spree::HasStatus
- Extended by:
- ActiveSupport::Concern
- Included in:
- Claim, DataRequest, EmailTemplate, Exchange, Fulfillment, FulfillmentItem, GiftCard, Import, ImportRow, Invitation, MaintenanceTaskRun, Payment, PriceList, Product, ProductSubmission, PurchaseOrder, Return, Seller, SellerPayout, SellerRequirementSubmission, SellerTransfer, ShippingLabel, StockTransfer, TaxExemptionCertificate
- Defined in:
- app/models/concerns/spree/has_status.rb
Overview
Declarative status column for models whose transitions belong to workflows rather than a state machine (docs/plans/6.0-service-workflows.md, decision 11).
class Spree::Return < Spree.base_class
include Spree::HasStatus
has_status :requested, :approved, :received, :refunded, :canceled,
default: :requested
end
Generates an inclusion validation, a predicate per value (#received?)
and a scope per value (.received) — nothing else. There are no events,
no transition graph and no callbacks: moving a record between statuses is
a workflow's job, which is what lets a transition take arguments, perform
gateway I/O outside a transaction, and compensate when a later step fails.
Values live in a class_attribute rather than a frozen constant so an extension can add its own without reopening core.