Module: Enum

Included in:
MangoModel::AccountType, MangoModel::AvsResult, MangoModel::BankingAliasType, MangoModel::BusinessType, MangoModel::CardStatus, MangoModel::CardType, MangoModel::CardValidity, MangoModel::CountryIso, MangoModel::CultureCode, MangoModel::CurrencyIso, MangoModel::DeclaredUboRefusedReasonType, MangoModel::DeclaredUboStatus, MangoModel::DepositType, MangoModel::DirectDebitType, MangoModel::DisputeDocRefusedReasonType, MangoModel::DisputeDocumentType, MangoModel::DisputeReasonType, MangoModel::DisputeStatus, MangoModel::DisputeType, MangoModel::DocumentStatus, MangoModel::DownloadFormat, MangoModel::EventType, MangoModel::FundsType, MangoModel::HookStatus, MangoModel::HookValidity, MangoModel::KycDocRefusedReasonType, MangoModel::KycDocumentType, MangoModel::KycLevel, MangoModel::LegalPersonType, MangoModel::MandateCultureCode, MangoModel::MandateExecutionType, MangoModel::MandateScheme, MangoModel::MandateStatus, MangoModel::MandateType, MangoModel::NaturalUserCapacity, MangoModel::PayInExecutionType, MangoModel::PayInPaymentType, MangoModel::PayOutPaymentType, MangoModel::PaymentStatus, MangoModel::PersonType, MangoModel::PlatformType, MangoModel::PreAuthorizationExecutionType, MangoModel::PreAuthorizationStatus, MangoModel::RefundReasonType, MangoModel::ReportStatus, MangoModel::ReportType, MangoModel::Sector, MangoModel::SecureMode, MangoModel::TransactionNature, MangoModel::TransactionStatus, MangoModel::TransactionType, MangoModel::UboDeclarationRefusedReasonType, MangoModel::UboDeclarationStatus, MangoPay::RateLimitInterval, MangoPay::SortDirection, MangoPay::SortField, StorageStrategy
Defined in:
lib/mangopay/util/enum.rb

Overview

Extend in order to apply methods for Enum instantiation.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Restrict enum instantiation to the value method.



5
6
7
8
9
# File 'lib/mangopay/util/enum.rb', line 5

def self.extended(base)
  base.class_eval do
    disable_instantiation
  end
end

Instance Method Details

#value_of(string) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/mangopay/util/enum.rb', line 11

def value_of(string)
  value = nil
  constants.each do |const|
    value = const_get const if const.to_s == string
  end
  value
end