Module: Glib::EnumSymbolization
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationRecord
- Defined in:
- app/models/concerns/glib/enum_symbolization.rb
Overview
Class-level helper that overrides one or more enum readers to return a symbol instead of Rails’ default string form. Lets callers compare with ‘record.status == :active` without having to remember which form they’re holding (see backend/01a_defensive_programming.md item 7).
Usage:
class Order < ApplicationRecord
enum :payment_status, { draft: 0, pending: 1, finalized: 2 }
enum :finalize_intent, { unknown: 0, charge: 1 }, prefix: true
enum_symbolize :payment_status, :finalize_intent
end