Module: Sqlx::Model
- Included in:
- Base
- Defined in:
- runtime/sqlx/model.rb,
runtime/sqlx/model.rbs
Overview
The declaration surface a model writes in its class body — the table/column pair the query layer assembles from, the hydration factory it walks with, and the enum factory. Extended onto Base so each arrives as a model class method.
Instance Method Summary collapse
-
#enum(pairs) ⇒ Enum
the hand-written enum declaration for table-oriented models: one validated object per enum, held in a model constant.
Instance Method Details
#enum(pairs) ⇒ Enum
the hand-written enum declaration for table-oriented models: one validated
object per enum, held in a model constant. It replaces the two parallel
constants a model would otherwise write by hand, whose pair can drift
silently. The name follows the mental model, but it generates no methods
(spinel has no metaprogramming); the members are the literal shape
spelled out in the @example below.
36 |
# File 'runtime/sqlx/model.rb', line 36
def enum: (Hash[Symbol, Integer] pairs) -> Enum
|