Sha256: b5ddb4b630a22277f20ba7c25c31534a0fc63bc89fa7a051e2dfaec909407f25
Contents?: true
Size: 803 Bytes
Versions: 4
Compression:
Stored size: 803 Bytes
Contents
module SolidusPaypalBraintree module CountryMapper extend ActiveSupport::Concern USA_VARIANTS = [ "the united states of america", "united states of america", "the united states", "united states", "us of a", "u.s.a.", "usa", "u.s.", "us" ] CANADA_VARIANTS = [ "canada", "ca" ] # Generates a hash mapping each variant of the country name to the same ISO # ie: { "usa" => "US", "united states" => "US", "canada" => "CA", ... } COUNTRY_MAP = { USA_VARIANTS => "US", CANADA_VARIANTS => "CA" }.flat_map { |variants, iso| variants.map { |v| [v, iso] } }.to_h included do def iso_from_name(country_name) COUNTRY_MAP[country_name.downcase.strip] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems