Class: Dinie::Internal::Model
- Inherits:
-
Object
- Object
- Dinie::Internal::Model
- Defined in:
- sig/dinie/runtime/model.rbs,
lib/dinie/runtime/model.rb
Overview
Base class for every generated model (architecture §5.1, RB3/RB18).
Gives POROs value-semantics without Data.define, so the floor stays at Ruby 3.1
(Block 0). A subclass declares its fields with Model.attribute in alphabetical order
(R-ORDER); the source-emission order is the single source of truth for to_h and
inspect, so the runtime never sorts at call time. Instances are frozen after
construction, mirroring the read-only character of the sdk-js models.
Direct Known Subclasses
ArticlesOfAssociationAttachment, ArticlesOfAssociationSubmitted, Bank, BiometricsSession, BiometricsSessionExchangeResponse, CompanyDocumentAttachment, CompanyDocumentSubmitted, Credential, CreditOffer, Customer, CustomerBankAccount, EiMeiDocumentsAttachment, EiMeiDocumentsSubmitted, EireliIncorporationStatementAttachment, EireliIncorporationStatementSubmitted, EmailAttachment, EmailSubmitted, Events::CreditOfferData, Events::CreditOfferEventData, Events::CustomerCreatedData, Events::CustomerDeniedData, Events::CustomerKycUpdatedData, Events::CustomerStatusData, Events::LoanActiveData, Events::LoanCreatedData, Events::LoanErrorDetails, Events::LoanPayment, Events::LoanPaymentReceivedData, Events::LoanProcessingData, Events::LoanSignatureReceivedData, Events::LoanSigner, Events::LoanStatusData, Events::WebhookEventBase, FixedInstallmentCreditOffer, Dinie::IdentityCnhAttachment, Dinie::IdentityCnhSubmitted, Dinie::IdentityRgAttachment, Dinie::IdentityRgSubmitted, Dinie::IncomeStatementAttachment, Dinie::IncomeStatementSubmitted, Kyc::Attachment, Kyc::AttachmentResponse, Kyc::Requirement, Kyc::Subject, Kyc::Submitted, KycAttachmentResponse, KycRequirement, KycSubject, Loan, ProofOfAddressAttachment, ProofOfAddressSubmitted, RangeInstallmentCreditOffer, SelfieAttachment, SelfieSubmitted, Simulation, Transaction, WebhookEndpoint, WebhookSecretRotation
Constant Summary collapse
- REDACTED_ATTRIBUTES =
PII attribute names redacted by #inspect. Kept in sync with the logger's body redaction list (architecture §9 / story 005, which owns the canonical set).
%i[ access_token account client_secret cnpj cpf cvv password phone secret ].freeze
Class Method Summary collapse
-
.attribute(*names) ⇒ void
Declare one or more attributes: defines an
attr_readerfor each and appends it to Model.attributes in declaration order. -
.attributes ⇒ Array<Symbol>
The declared attribute names, in declaration (R-ORDER) order.
-
.inherited(subclass) ⇒ void
Carry the parent's attribute list into each subclass.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Value-equality: same class and same attribute values.
-
#deconstruct_keys(_keys) ⇒ Hash{Symbol => Object}
Enable pattern matching (
case model; in {status: "active"}). -
#hash ⇒ Integer
Consistent with #eql? so instances work as Hash keys.
-
#initialize(**attrs) ⇒ Model
constructor
Build a frozen instance from keyword arguments — one per declared attribute.
-
#inspect ⇒ String
Like #to_h, but with PII redacted — safe for logs and the console.
-
#to_h ⇒ Hash{Symbol => Object}
(also: #to_hash)
Attributes in declaration (R-ORDER) order — deterministic.
Constructor Details
#initialize(**attrs) ⇒ Model
Build a frozen instance from keyword arguments — one per declared attribute.
Every declared attribute is required (hydration always passes a value, nil
included), and unknown keywords are rejected, so a contract drift surfaces loudly
instead of silently dropping data.
28 |
# File 'sig/dinie/runtime/model.rbs', line 28
def initialize: (**untyped attrs) -> void
|
Class Method Details
.attribute(*names) ⇒ void
This method returns an undefined value.
Declare one or more attributes: defines an attr_reader for each and appends it
to attributes in declaration order. Idempotent per name.
22 |
# File 'sig/dinie/runtime/model.rbs', line 22
def self.attribute: (*Symbol | String names) -> void
|
.attributes ⇒ Array<Symbol>
The declared attribute names, in declaration (R-ORDER) order. Subclasses inherit and may extend their parent's list.
19 |
# File 'sig/dinie/runtime/model.rbs', line 19
def self.attributes: () -> Array[Symbol]
|
.inherited(subclass) ⇒ void
This method returns an undefined value.
Carry the parent's attribute list into each subclass.
25 |
# File 'sig/dinie/runtime/model.rbs', line 25
def self.inherited: (Class subclass) -> void
|
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Value-equality: same class and same attribute values.
38 |
# File 'sig/dinie/runtime/model.rbs', line 38
def ==: (untyped other) -> bool
|
#deconstruct_keys(_keys) ⇒ Hash{Symbol => Object}
Enable pattern matching (case model; in {status: "active"}).
35 |
# File 'sig/dinie/runtime/model.rbs', line 35
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
#hash ⇒ Integer
Returns consistent with #eql? so instances work as Hash keys.
132 |
# File 'lib/dinie/runtime/model.rb', line 132
def hash: () -> Integer
|
#inspect ⇒ String
Like #to_h, but with PII redacted — safe for logs and the console.
44 |
# File 'sig/dinie/runtime/model.rbs', line 44
def inspect: () -> String
|
#to_h ⇒ Hash{Symbol => Object} Also known as: to_hash
Returns attributes in declaration (R-ORDER) order — deterministic.
31 |
# File 'sig/dinie/runtime/model.rbs', line 31
def to_h: () -> Hash[Symbol, untyped]
|