Module: Orb::Internal::Type::Enum Private

Includes:
Converter, Util::SorbetRuntimeSupport
Included in:
Models::Alert::Type, Models::AlertCreateForCustomerParams::Type, Models::AlertCreateForExternalCustomerParams::Type, Models::AlertCreateForSubscriptionParams::Type, Models::AmountDiscount::DiscountType, Models::AmountDiscountInterval::DiscountType, Models::BillableMetric::Status, Models::BillingCycleConfiguration::DurationUnit, Models::BillingCycleRelativeDate, Models::CreditNote::Discount::DiscountType, Models::CreditNote::LineItem::Discount::DiscountType, Models::CreditNote::MaximumAmountAdjustment::DiscountType, Models::CreditNote::Reason, Models::CreditNote::Type, Models::CreditNoteCreateParams::Reason, Models::CustomExpiration::DurationUnit, Models::Customer::AccountingSyncConfiguration::AccountingProvider::ProviderType, Models::Customer::PaymentProvider, Models::CustomerCreateParams::PaymentProvider, Models::CustomerTaxID::Country, Models::CustomerTaxID::Type, Models::CustomerUpdateByExternalIDParams::PaymentProvider, Models::CustomerUpdateParams::PaymentProvider, Models::Customers::BalanceTransactionCreateParams::Type, Models::Customers::BalanceTransactionCreateResponse::Action, Models::Customers::BalanceTransactionCreateResponse::Type, Models::Customers::BalanceTransactionListResponse::Action, Models::Customers::BalanceTransactionListResponse::Type, Models::Customers::CostListByExternalIDParams::ViewMode, Models::Customers::CostListParams::ViewMode, Models::Customers::CreditListByExternalIDResponse::Status, Models::Customers::CreditListResponse::Status, Models::Customers::Credits::AmendmentLedgerEntry::EntryStatus, Models::Customers::Credits::AmendmentLedgerEntry::EntryType, Models::Customers::Credits::CreditBlockExpiryLedgerEntry::EntryStatus, Models::Customers::Credits::CreditBlockExpiryLedgerEntry::EntryType, Models::Customers::Credits::DecrementLedgerEntry::EntryStatus, Models::Customers::Credits::DecrementLedgerEntry::EntryType, Models::Customers::Credits::ExpirationChangeLedgerEntry::EntryStatus, Models::Customers::Credits::ExpirationChangeLedgerEntry::EntryType, Models::Customers::Credits::IncrementLedgerEntry::EntryStatus, Models::Customers::Credits::IncrementLedgerEntry::EntryType, Models::Customers::Credits::LedgerCreateEntryByExternalIDParams::EntryType, Models::Customers::Credits::LedgerCreateEntryByExternalIDParams::VoidReason, Models::Customers::Credits::LedgerCreateEntryParams::EntryType, Models::Customers::Credits::LedgerCreateEntryParams::VoidReason, Models::Customers::Credits::LedgerListByExternalIDParams::EntryStatus, Models::Customers::Credits::LedgerListByExternalIDParams::EntryType, Models::Customers::Credits::LedgerListParams::EntryStatus, Models::Customers::Credits::LedgerListParams::EntryType, Models::Customers::Credits::TopUpCreateByExternalIDParams::ExpiresAfterUnit, Models::Customers::Credits::TopUpCreateByExternalIDResponse::ExpiresAfterUnit, Models::Customers::Credits::TopUpCreateParams::ExpiresAfterUnit, Models::Customers::Credits::TopUpCreateResponse::ExpiresAfterUnit, Models::Customers::Credits::TopUpListByExternalIDResponse::ExpiresAfterUnit, Models::Customers::Credits::TopUpListResponse::ExpiresAfterUnit, Models::Customers::Credits::VoidInitiatedLedgerEntry::EntryStatus, Models::Customers::Credits::VoidInitiatedLedgerEntry::EntryType, Models::Customers::Credits::VoidLedgerEntry::EntryStatus, Models::Customers::Credits::VoidLedgerEntry::EntryType, Models::DiscountOverride::DiscountType, Models::Events::BackfillCloseResponse::Status, Models::Events::BackfillCreateResponse::Status, Models::Events::BackfillFetchResponse::Status, Models::Events::BackfillListResponse::Status, Models::Events::BackfillRevertResponse::Status, Models::Invoice::CustomerBalanceTransaction::Action, Models::Invoice::CustomerBalanceTransaction::Type, Models::Invoice::InvoiceSource, Models::Invoice::PaymentAttempt::PaymentProvider, Models::Invoice::Status, Models::InvoiceCreateParams::LineItem::ModelType, Models::InvoiceFetchUpcomingResponse::CustomerBalanceTransaction::Action, Models::InvoiceFetchUpcomingResponse::CustomerBalanceTransaction::Type, Models::InvoiceFetchUpcomingResponse::InvoiceSource, Models::InvoiceFetchUpcomingResponse::PaymentAttempt::PaymentProvider, Models::InvoiceFetchUpcomingResponse::Status, Models::InvoiceListParams::DateType, Models::InvoiceListParams::Status, Models::Item::ExternalConnection::ExternalConnectionName, Models::ItemUpdateParams::ExternalConnection::ExternalConnectionName, Models::MatrixSubLineItem::Type, Models::MonetaryAmountDiscountAdjustment::AdjustmentType, Models::MonetaryMaximumAdjustment::AdjustmentType, Models::MonetaryMinimumAdjustment::AdjustmentType, Models::MonetaryPercentageDiscountAdjustment::AdjustmentType, Models::MonetaryUsageDiscountAdjustment::AdjustmentType, Models::MutatedSubscription::Status, Models::NewAllocationPrice::Cadence, Models::NewAmountDiscount::AdjustmentType, Models::NewAmountDiscount::AppliesToAll, Models::NewAmountDiscount::PriceType, Models::NewAvalaraTaxConfiguration::TaxProvider, Models::NewBillingCycleConfiguration::DurationUnit, Models::NewFloatingBPSPrice::Cadence, Models::NewFloatingBPSPrice::ModelType, Models::NewFloatingBulkBPSPrice::Cadence, Models::NewFloatingBulkBPSPrice::ModelType, Models::NewFloatingBulkPrice::Cadence, Models::NewFloatingBulkPrice::ModelType, Models::NewFloatingBulkWithProrationPrice::Cadence, Models::NewFloatingBulkWithProrationPrice::ModelType, Models::NewFloatingCumulativeGroupedBulkPrice::Cadence, Models::NewFloatingCumulativeGroupedBulkPrice::ModelType, Models::NewFloatingGroupedAllocationPrice::Cadence, Models::NewFloatingGroupedAllocationPrice::ModelType, Models::NewFloatingGroupedTieredPackagePrice::Cadence, Models::NewFloatingGroupedTieredPackagePrice::ModelType, Models::NewFloatingGroupedTieredPrice::Cadence, Models::NewFloatingGroupedTieredPrice::ModelType, Models::NewFloatingGroupedWithMeteredMinimumPrice::Cadence, Models::NewFloatingGroupedWithMeteredMinimumPrice::ModelType, Models::NewFloatingGroupedWithProratedMinimumPrice::Cadence, Models::NewFloatingGroupedWithProratedMinimumPrice::ModelType, Models::NewFloatingMatrixPrice::Cadence, Models::NewFloatingMatrixPrice::ModelType, Models::NewFloatingMatrixWithAllocationPrice::Cadence, Models::NewFloatingMatrixWithAllocationPrice::ModelType, Models::NewFloatingMatrixWithDisplayNamePrice::Cadence, Models::NewFloatingMatrixWithDisplayNamePrice::ModelType, Models::NewFloatingMaxGroupTieredPackagePrice::Cadence, Models::NewFloatingMaxGroupTieredPackagePrice::ModelType, Models::NewFloatingPackagePrice::Cadence, Models::NewFloatingPackagePrice::ModelType, Models::NewFloatingPackageWithAllocationPrice::Cadence, Models::NewFloatingPackageWithAllocationPrice::ModelType, Models::NewFloatingScalableMatrixWithTieredPricingPrice::Cadence, Models::NewFloatingScalableMatrixWithTieredPricingPrice::ModelType, Models::NewFloatingScalableMatrixWithUnitPricingPrice::Cadence, Models::NewFloatingScalableMatrixWithUnitPricingPrice::ModelType, Models::NewFloatingThresholdTotalAmountPrice::Cadence, Models::NewFloatingThresholdTotalAmountPrice::ModelType, Models::NewFloatingTieredBPSPrice::Cadence, Models::NewFloatingTieredBPSPrice::ModelType, Models::NewFloatingTieredPackagePrice::Cadence, Models::NewFloatingTieredPackagePrice::ModelType, Models::NewFloatingTieredPackageWithMinimumPrice::Cadence, Models::NewFloatingTieredPackageWithMinimumPrice::ModelType, Models::NewFloatingTieredPrice::Cadence, Models::NewFloatingTieredPrice::ModelType, Models::NewFloatingTieredWithMinimumPrice::Cadence, Models::NewFloatingTieredWithMinimumPrice::ModelType, Models::NewFloatingTieredWithProrationPrice::Cadence, Models::NewFloatingTieredWithProrationPrice::ModelType, Models::NewFloatingUnitPrice::Cadence, Models::NewFloatingUnitPrice::ModelType, Models::NewFloatingUnitWithPercentPrice::Cadence, Models::NewFloatingUnitWithPercentPrice::ModelType, Models::NewFloatingUnitWithProrationPrice::Cadence, Models::NewFloatingUnitWithProrationPrice::ModelType, Models::NewMaximum::AdjustmentType, Models::NewMaximum::AppliesToAll, Models::NewMaximum::PriceType, Models::NewMinimum::AdjustmentType, Models::NewMinimum::AppliesToAll, Models::NewMinimum::PriceType, Models::NewPercentageDiscount::AdjustmentType, Models::NewPercentageDiscount::AppliesToAll, Models::NewPercentageDiscount::PriceType, Models::NewPlanBPSPrice::Cadence, Models::NewPlanBPSPrice::ModelType, Models::NewPlanBulkBPSPrice::Cadence, Models::NewPlanBulkBPSPrice::ModelType, Models::NewPlanBulkPrice::Cadence, Models::NewPlanBulkPrice::ModelType, Models::NewPlanBulkWithProrationPrice::Cadence, Models::NewPlanBulkWithProrationPrice::ModelType, Models::NewPlanCumulativeGroupedBulkPrice::Cadence, Models::NewPlanCumulativeGroupedBulkPrice::ModelType, Models::NewPlanGroupedAllocationPrice::Cadence, Models::NewPlanGroupedAllocationPrice::ModelType, Models::NewPlanGroupedTieredPackagePrice::Cadence, Models::NewPlanGroupedTieredPackagePrice::ModelType, Models::NewPlanGroupedTieredPrice::Cadence, Models::NewPlanGroupedTieredPrice::ModelType, Models::NewPlanGroupedWithMeteredMinimumPrice::Cadence, Models::NewPlanGroupedWithMeteredMinimumPrice::ModelType, Models::NewPlanGroupedWithProratedMinimumPrice::Cadence, Models::NewPlanGroupedWithProratedMinimumPrice::ModelType, Models::NewPlanMatrixPrice::Cadence, Models::NewPlanMatrixPrice::ModelType, Models::NewPlanMatrixWithAllocationPrice::Cadence, Models::NewPlanMatrixWithAllocationPrice::ModelType, Models::NewPlanMatrixWithDisplayNamePrice::Cadence, Models::NewPlanMatrixWithDisplayNamePrice::ModelType, Models::NewPlanMaxGroupTieredPackagePrice::Cadence, Models::NewPlanMaxGroupTieredPackagePrice::ModelType, Models::NewPlanPackagePrice::Cadence, Models::NewPlanPackagePrice::ModelType, Models::NewPlanPackageWithAllocationPrice::Cadence, Models::NewPlanPackageWithAllocationPrice::ModelType, Models::NewPlanScalableMatrixWithTieredPricingPrice::Cadence, Models::NewPlanScalableMatrixWithTieredPricingPrice::ModelType, Models::NewPlanScalableMatrixWithUnitPricingPrice::Cadence, Models::NewPlanScalableMatrixWithUnitPricingPrice::ModelType, Models::NewPlanThresholdTotalAmountPrice::Cadence, Models::NewPlanThresholdTotalAmountPrice::ModelType, Models::NewPlanTierWithProrationPrice::Cadence, Models::NewPlanTierWithProrationPrice::ModelType, Models::NewPlanTieredBPSPrice::Cadence, Models::NewPlanTieredBPSPrice::ModelType, Models::NewPlanTieredPackagePrice::Cadence, Models::NewPlanTieredPackagePrice::ModelType, Models::NewPlanTieredPackageWithMinimumPrice::Cadence, Models::NewPlanTieredPackageWithMinimumPrice::ModelType, Models::NewPlanTieredPrice::Cadence, Models::NewPlanTieredPrice::ModelType, Models::NewPlanTieredWithMinimumPrice::Cadence, Models::NewPlanTieredWithMinimumPrice::ModelType, Models::NewPlanUnitPrice::Cadence, Models::NewPlanUnitPrice::ModelType, Models::NewPlanUnitWithPercentPrice::Cadence, Models::NewPlanUnitWithPercentPrice::ModelType, Models::NewPlanUnitWithProrationPrice::Cadence, Models::NewPlanUnitWithProrationPrice::ModelType, Models::NewSphereConfiguration::TaxProvider, Models::NewSubscriptionBPSPrice::Cadence, Models::NewSubscriptionBPSPrice::ModelType, Models::NewSubscriptionBulkBPSPrice::Cadence, Models::NewSubscriptionBulkBPSPrice::ModelType, Models::NewSubscriptionBulkPrice::Cadence, Models::NewSubscriptionBulkPrice::ModelType, Models::NewSubscriptionBulkWithProrationPrice::Cadence, Models::NewSubscriptionBulkWithProrationPrice::ModelType, Models::NewSubscriptionCumulativeGroupedBulkPrice::Cadence, Models::NewSubscriptionCumulativeGroupedBulkPrice::ModelType, Models::NewSubscriptionGroupedAllocationPrice::Cadence, Models::NewSubscriptionGroupedAllocationPrice::ModelType, Models::NewSubscriptionGroupedTieredPackagePrice::Cadence, Models::NewSubscriptionGroupedTieredPackagePrice::ModelType, Models::NewSubscriptionGroupedTieredPrice::Cadence, Models::NewSubscriptionGroupedTieredPrice::ModelType, Models::NewSubscriptionGroupedWithMeteredMinimumPrice::Cadence, Models::NewSubscriptionGroupedWithMeteredMinimumPrice::ModelType, Models::NewSubscriptionGroupedWithProratedMinimumPrice::Cadence, Models::NewSubscriptionGroupedWithProratedMinimumPrice::ModelType, Models::NewSubscriptionMatrixPrice::Cadence, Models::NewSubscriptionMatrixPrice::ModelType, Models::NewSubscriptionMatrixWithAllocationPrice::Cadence, Models::NewSubscriptionMatrixWithAllocationPrice::ModelType, Models::NewSubscriptionMatrixWithDisplayNamePrice::Cadence, Models::NewSubscriptionMatrixWithDisplayNamePrice::ModelType, Models::NewSubscriptionMaxGroupTieredPackagePrice::Cadence, Models::NewSubscriptionMaxGroupTieredPackagePrice::ModelType, Models::NewSubscriptionPackagePrice::Cadence, Models::NewSubscriptionPackagePrice::ModelType, Models::NewSubscriptionPackageWithAllocationPrice::Cadence, Models::NewSubscriptionPackageWithAllocationPrice::ModelType, Models::NewSubscriptionScalableMatrixWithTieredPricingPrice::Cadence, Models::NewSubscriptionScalableMatrixWithTieredPricingPrice::ModelType, Models::NewSubscriptionScalableMatrixWithUnitPricingPrice::Cadence, Models::NewSubscriptionScalableMatrixWithUnitPricingPrice::ModelType, Models::NewSubscriptionThresholdTotalAmountPrice::Cadence, Models::NewSubscriptionThresholdTotalAmountPrice::ModelType, Models::NewSubscriptionTierWithProrationPrice::Cadence, Models::NewSubscriptionTierWithProrationPrice::ModelType, Models::NewSubscriptionTieredBPSPrice::Cadence, Models::NewSubscriptionTieredBPSPrice::ModelType, Models::NewSubscriptionTieredPackagePrice::Cadence, Models::NewSubscriptionTieredPackagePrice::ModelType, Models::NewSubscriptionTieredPackageWithMinimumPrice::Cadence, Models::NewSubscriptionTieredPackageWithMinimumPrice::ModelType, Models::NewSubscriptionTieredPrice::Cadence, Models::NewSubscriptionTieredPrice::ModelType, Models::NewSubscriptionTieredWithMinimumPrice::Cadence, Models::NewSubscriptionTieredWithMinimumPrice::ModelType, Models::NewSubscriptionUnitPrice::Cadence, Models::NewSubscriptionUnitPrice::ModelType, Models::NewSubscriptionUnitWithPercentPrice::Cadence, Models::NewSubscriptionUnitWithPercentPrice::ModelType, Models::NewSubscriptionUnitWithProrationPrice::Cadence, Models::NewSubscriptionUnitWithProrationPrice::ModelType, Models::NewTaxJarConfiguration::TaxProvider, Models::NewUsageDiscount::AdjustmentType, Models::NewUsageDiscount::AppliesToAll, Models::NewUsageDiscount::PriceType, Models::OtherSubLineItem::Type, Models::PercentageDiscount::DiscountType, Models::PercentageDiscountInterval::DiscountType, Models::Plan::PlanPhase::DurationUnit, Models::Plan::Status, Models::Plan::TrialConfig::TrialPeriodUnit, Models::PlanCreateParams::PlanPhase::DurationUnit, Models::PlanCreateParams::Status, Models::PlanListParams::Status, Models::PlanPhaseAmountDiscountAdjustment::AdjustmentType, Models::PlanPhaseMaximumAdjustment::AdjustmentType, Models::PlanPhaseMinimumAdjustment::AdjustmentType, Models::PlanPhasePercentageDiscountAdjustment::AdjustmentType, Models::PlanPhaseUsageDiscountAdjustment::AdjustmentType, Models::PlanVersionPhase::DurationUnit, Models::Price::BPS::Cadence, Models::Price::BPS::PriceType, Models::Price::Bulk::Cadence, Models::Price::Bulk::PriceType, Models::Price::BulkBPS::Cadence, Models::Price::BulkBPS::PriceType, Models::Price::BulkWithProration::Cadence, Models::Price::BulkWithProration::PriceType, Models::Price::CumulativeGroupedBulk::Cadence, Models::Price::CumulativeGroupedBulk::PriceType, Models::Price::GroupedAllocation::Cadence, Models::Price::GroupedAllocation::PriceType, Models::Price::GroupedTiered::Cadence, Models::Price::GroupedTiered::PriceType, Models::Price::GroupedTieredPackage::Cadence, Models::Price::GroupedTieredPackage::PriceType, Models::Price::GroupedWithMeteredMinimum::Cadence, Models::Price::GroupedWithMeteredMinimum::PriceType, Models::Price::GroupedWithMinMaxThresholds::Cadence, Models::Price::GroupedWithMinMaxThresholds::PriceType, Models::Price::GroupedWithProratedMinimum::Cadence, Models::Price::GroupedWithProratedMinimum::PriceType, Models::Price::Matrix::Cadence, Models::Price::Matrix::PriceType, Models::Price::MatrixWithAllocation::Cadence, Models::Price::MatrixWithAllocation::PriceType, Models::Price::MatrixWithDisplayName::Cadence, Models::Price::MatrixWithDisplayName::PriceType, Models::Price::MaxGroupTieredPackage::Cadence, Models::Price::MaxGroupTieredPackage::PriceType, Models::Price::Package::Cadence, Models::Price::Package::PriceType, Models::Price::PackageWithAllocation::Cadence, Models::Price::PackageWithAllocation::PriceType, Models::Price::ScalableMatrixWithTieredPricing::Cadence, Models::Price::ScalableMatrixWithTieredPricing::PriceType, Models::Price::ScalableMatrixWithUnitPricing::Cadence, Models::Price::ScalableMatrixWithUnitPricing::PriceType, Models::Price::ThresholdTotalAmount::Cadence, Models::Price::ThresholdTotalAmount::PriceType, Models::Price::Tiered::Cadence, Models::Price::Tiered::PriceType, Models::Price::TieredBPS::Cadence, Models::Price::TieredBPS::PriceType, Models::Price::TieredPackage::Cadence, Models::Price::TieredPackage::PriceType, Models::Price::TieredPackageWithMinimum::Cadence, Models::Price::TieredPackageWithMinimum::PriceType, Models::Price::TieredWithMinimum::Cadence, Models::Price::TieredWithMinimum::PriceType, Models::Price::TieredWithProration::Cadence, Models::Price::TieredWithProration::PriceType, Models::Price::Unit::Cadence, Models::Price::Unit::PriceType, Models::Price::UnitWithPercent::Cadence, Models::Price::UnitWithPercent::PriceType, Models::Price::UnitWithProration::Cadence, Models::Price::UnitWithProration::PriceType, Models::PriceCreateParams::Cadence, Models::PriceCreateParams::ModelType, Models::Subscription::Status, Models::SubscriptionCancelParams::CancelOption, Models::SubscriptionChangeApplyResponse::Status, Models::SubscriptionChangeCancelResponse::Status, Models::SubscriptionChangeRetrieveResponse::Status, Models::SubscriptionCreateParams::ExternalMarketplace, Models::SubscriptionFetchCostsParams::ViewMode, Models::SubscriptionFetchUsageParams::Granularity, Models::SubscriptionFetchUsageParams::ViewMode, Models::SubscriptionListParams::Status, Models::SubscriptionRedeemCouponParams::ChangeOption, Models::SubscriptionSchedulePlanChangeParams::BillingCycleAlignment, Models::SubscriptionSchedulePlanChangeParams::ChangeOption, Models::SubscriptionUpdateFixedFeeQuantityParams::ChangeOption, Models::SubscriptionUsage::GroupedSubscriptionUsage::Data::ViewMode, Models::SubscriptionUsage::UngroupedSubscriptionUsage::Data::ViewMode, Models::TierSubLineItem::Type, Models::TieredConversionRateConfig::ConversionRateType, Models::TransformPriceFilter::Field, Models::TransformPriceFilter::Operator, Models::TrialDiscount::DiscountType, Models::UnitConversionRateConfig::ConversionRateType, Models::UsageDiscount::DiscountType, Models::UsageDiscountInterval::DiscountType
Defined in:
lib/orb/internal/type/enum.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

A value from among a specified list of options. OpenAPI enum values map to Ruby values in the SDK as follows:

  1. boolean => true | false

  2. integer => Integer

  3. float => Float

  4. string => Symbol

We can therefore convert string values to Symbols, but can’t convert other values safely.

Examples:

# `billing_cycle_relative_date` is a `Orb::BillingCycleRelativeDate`
case billing_cycle_relative_date
when Orb::BillingCycleRelativeDate::START_OF_TERM
  # ...
when Orb::BillingCycleRelativeDate::END_OF_TERM
  # ...
else
  puts(billing_cycle_relative_date)
end
case billing_cycle_relative_date
in :start_of_term
  # ...
in :end_of_term
  # ...
else
  puts(billing_cycle_relative_date)
end

Instance Method Summary collapse

Methods included from Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, to_sorbet_type

Methods included from Converter

coerce, dump, inspect, meta_info, new_coerce_state, type_info

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:



60
61
62
63
64
# File 'lib/orb/internal/type/enum.rb', line 60

def ==(other)
  # rubocop:disable Style/CaseEquality
  Orb::Internal::Type::Enum === other && other.values.to_set == values.to_set
  # rubocop:enable Style/CaseEquality
end

#===(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:



53
# File 'lib/orb/internal/type/enum.rb', line 53

def ===(other) = values.include?(other)

#coerce(value, state:) ⇒ Symbol, Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Unlike with primitives, ‘Enum` additionally validates that the value is a member of the enum.

Parameters:

  • value (String, Symbol, Object)
  • state (Hash{Symbol=>Object})

    .

    @option state [Boolean] :translate_names

    @option state [Boolean] :strictness

    @option state [HashSymbol=>Object] :exactness

    @option state [Class<StandardError>] :error

    @option state [Integer] :branched

Returns:

  • (Symbol, Object)


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/orb/internal/type/enum.rb', line 91

def coerce(value, state:)
  exactness = state.fetch(:exactness)
  val = value.is_a?(String) ? value.to_sym : value

  if values.include?(val)
    exactness[:yes] += 1
    val
  elsif values.first&.class == val.class
    exactness[:maybe] += 1
    value
  else
    exactness[:no] += 1
    state[:error] = TypeError.new("#{value.class} can't be coerced into #{self}")
    value
  end
end

#dump(value, state: ) ⇒ Symbol, Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Symbol, Object)
  • state (Hash{Symbol=>Object}) (defaults to: )

    .

    @option state [Boolean] :can_retry

Returns:

  • (Symbol, Object)


# File 'lib/orb/internal/type/enum.rb', line 108

#hashInteger

Returns:

  • (Integer)


69
# File 'lib/orb/internal/type/enum.rb', line 69

def hash = values.to_set.hash

#inspect(depth: 0) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • depth (Integer) (defaults to: 0)

Returns:

  • (String)


139
140
141
142
143
144
145
146
147
148
# File 'lib/orb/internal/type/enum.rb', line 139

def inspect(depth: 0)
  if depth.positive?
    return is_a?(Module) ? super() : self.class.name
  end

  members = values.map { Orb::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
  prefix = is_a?(Module) ? name : self.class.name

  "#{prefix}[#{members.join(' | ')}]"
end

#to_sorbet_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Object)


122
123
124
125
126
127
128
129
130
131
132
# File 'lib/orb/internal/type/enum.rb', line 122

def to_sorbet_type
  types = values.map { Orb::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
  case types
  in []
    T.noreturn
  in [type]
    type
  else
    T.any(*types)
  end
end

#valuesArray<NilClass, Boolean, Integer, Float, Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

All of the valid Symbol values for this enum.

Returns:

  • (Array<NilClass, Boolean, Integer, Float, Symbol>)


46
# File 'lib/orb/internal/type/enum.rb', line 46

def values = constants.map { const_get(_1) }