Sha256: 1391f0c183fddaa9a223886c6a62de3a5175d257e9d22b1454ddc8258bda8c76
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 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 @locale = :en 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 behaviour_str = LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.behaviour", locale: locale, default: :unknown) return behaviour_str unless fraud_notice && fraudulent_code? "#{behaviour_str} #{LOCALE_LIBRARY.dig(path: 'issuer_response_codes.fraud_notice')}" end def fraudulent_code? @fraudulent_code ||= LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.fraudulent_codes", locale: locale) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
issuer_response_codes-0.2.5 | lib/issuer_response_codes/code.rb |