Sha256: 7ce7c585d42e6a51378feefd605ee3a0a3bb100827a9825ca5e741653238c178
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module IssuerResponseCodes class Code attr_reader :id, :target, :locale, :fraud_notice NOT_PROVIDED = ::Object.new def initialize(id:, target: :merchant, locale: :en, fraud_notice: NOT_PROVIDED) @id = id @target = target @locale = locale raise IllegalLocale, "No such locale: #{locale.inspect}" unless AVAILABLE_LOCALES.include?(locale) raise IllegalTarget, "No such target: #{target.inspect}" unless AVAILABLE_TARGETS.include?(target) if fraud_notice != NOT_PROVIDED @fraud_notice = fraud_notice return end @fraud_notice = target == :merchant end def humanize "#{reason} #{behaviour}" end alias description humanize def reason LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.targeted.#{target}", locale: locale, default: :unknown) end def behaviour fraud_notice_str = fraud_notice ? LOCALE_LIBRARY.dig(path: 'issuer_response_codes.fraud_notice') : '' LOCALE_LIBRARY.dig(path: id, substitute: fraud_notice_str, scope: "issuer_response_codes.behaviour", locale: locale, default: :unknown) end end end
Version data entries
4 entries across 4 versions & 1 rubygems