Module: Pago::V2026_04::Unions::Benefit
- Defined in:
- lib/pago/v2026_04/unions.rb,
sig/pago/v2026_04/generated.rbs
Overview
Variants: Models::BenefitCustom, Models::BenefitDiscord, Models::BenefitGitHubRepository, Models::BenefitDownloadables, Models::BenefitLicenseKeys, Models::BenefitMeterCredit, Models::BenefitFeatureFlag, Models::BenefitSlackSharedChannel.
Constant Summary collapse
- DISCRIMINATOR =
"type"
Class Method Summary collapse
-
.from_json(data) ⇒ Object?
The resolved variant, or the raw payload.
-
.mapping ⇒ Hash{String => Class}
Discriminator value to model class.
-
.variants ⇒ Array<Class>
Every model this union can resolve to.
Class Method Details
.from_json(data) ⇒ Object?
Returns the resolved variant, or the raw payload.
38 39 40 41 |
# File 'lib/pago/v2026_04/unions.rb', line 38 def self.from_json(data) data = ::JSON.parse(data) if data.is_a?(String) ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants) end |
.mapping ⇒ Hash{String => Class}
Returns discriminator value to model class.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pago/v2026_04/unions.rb', line 18 def self.mapping @mapping ||= { "custom" => Models::BenefitCustom, "discord" => Models::BenefitDiscord, "downloadables" => Models::BenefitDownloadables, "feature_flag" => Models::BenefitFeatureFlag, "github_repository" => Models::BenefitGitHubRepository, "license_keys" => Models::BenefitLicenseKeys, "meter_credit" => Models::BenefitMeterCredit, "slack_shared_channel" => Models::BenefitSlackSharedChannel }.freeze end |
.variants ⇒ Array<Class>
Returns every model this union can resolve to.
32 33 34 |
# File 'lib/pago/v2026_04/unions.rb', line 32 def self.variants @variants ||= [Models::BenefitCustom, Models::BenefitDiscord, Models::BenefitGitHubRepository, Models::BenefitDownloadables, Models::BenefitLicenseKeys, Models::BenefitMeterCredit, Models::BenefitFeatureFlag, Models::BenefitSlackSharedChannel].freeze end |