Class: IssuerResponseCodes::LocaleLibrary
- Inherits:
-
Object
- Object
- IssuerResponseCodes::LocaleLibrary
- Defined in:
- lib/issuer_response_codes/locale_library.rb
Overview
Stores the translations of codes.
Instance Attribute Summary collapse
-
#locale_hash ⇒ Object
readonly
Returns the value of attribute locale_hash.
Instance Method Summary collapse
-
#dig(path:, locale: :en, scope: '', default: nil) ⇒ Object
(also: #[])
: (path: String | Symbol, ?locale: Symbol, ?scope: String, ?default: Symbol | String?) -> untyped.
-
#initialize ⇒ LocaleLibrary
constructor
: -> void.
-
#issuer_response_codes(locale: :en) ⇒ Object
: (?locale: Symbol) -> Hash[Symbol, Hash[Symbol, untyped]].
-
#tds_codes(locale: :en) ⇒ Object
: (?locale: Symbol) -> Hash[Symbol, Hash[Symbol, untyped]].
Constructor Details
#initialize ⇒ LocaleLibrary
: -> void
12 13 14 15 16 17 18 |
# File 'lib/issuer_response_codes/locale_library.rb', line 12 def initialize @locale_hash = {} AVAILABLE_LOCALES.each do |locale| load_locale(locale) end end |
Instance Attribute Details
#locale_hash ⇒ Object (readonly)
Returns the value of attribute locale_hash.
9 10 11 |
# File 'lib/issuer_response_codes/locale_library.rb', line 9 def locale_hash @locale_hash end |
Instance Method Details
#dig(path:, locale: :en, scope: '', default: nil) ⇒ Object Also known as: []
: (path: String | Symbol, ?locale: Symbol, ?scope: String, ?default: Symbol | String?) -> untyped
21 22 23 |
# File 'lib/issuer_response_codes/locale_library.rb', line 21 def dig(path:, locale: :en, scope: '', default: nil) __dig__(path: path, locale: locale, scope: scope, default: default) end |
#issuer_response_codes(locale: :en) ⇒ Object
: (?locale: Symbol) -> Hash[Symbol, Hash[Symbol, untyped]]
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/issuer_response_codes/locale_library.rb', line 27 def issuer_response_codes(locale: :en) behaviours = locale_hash.dig(locale, :issuer_response_codes, :behaviour) cardholder_reasons = locale_hash.dig(locale, :issuer_response_codes, :targeted, :cardholder) merchant_reasons = locale_hash.dig(locale, :issuer_response_codes, :targeted, :merchant) merchant_reasons.to_h do |code, merchant_reason| [ code, { merchant_reason: merchant_reason, cardholder_reason: cardholder_reasons[code], behaviour: behaviours[code], fraudulent: Code::FRAUDULENT_IDS.include?(code.to_s), }, ] end end |
#tds_codes(locale: :en) ⇒ Object
: (?locale: Symbol) -> Hash[Symbol, Hash[Symbol, untyped]]
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/issuer_response_codes/locale_library.rb', line 46 def tds_codes(locale: :en) behaviours = locale_hash.dig(locale, :tds_status_codes, :behaviour) cardholder_reasons = locale_hash.dig(locale, :tds_status_codes, :targeted, :cardholder) merchant_reasons = locale_hash.dig(locale, :tds_status_codes, :targeted, :merchant) merchant_reasons.to_h do |code, merchant_reason| [ code, { merchant_reason: merchant_reason, cardholder_reason: cardholder_reasons[code], behaviour: behaviours[code], fraudulent: TdsCode::FRAUDULENT_IDS.include?(code.to_s), }, ] end end |