Sha256: 9728cb2abcb16e8418dfcb0c09d381f0c2136431836d75615a323ec2db6a3224
Contents?: true
Size: 675 Bytes
Versions: 17
Compression:
Stored size: 675 Bytes
Contents
# frozen_string_literal: true module SolidusPaypalCommercePlatform class StateGuesser def initialize(state_name, country) @state_name = state_name @country = country end def guess carmen_state = state_list.find{ |s| s.name == @state_name || s.code == @state_name } return if carmen_state.blank? guessed_state = spree_state(carmen_state.name) guessed_state || spree_state(carmen_state.parent.name) end private def state_list Carmen::Country.coded(@country.iso).subregions.map{ |s| [s, s.subregions] }.flatten end def spree_state(name) ::Spree::State.find_by(name: name) end end end
Version data entries
17 entries across 17 versions & 1 rubygems