Class: SolidusPaypalCommercePlatform::StateGuesser

Inherits:
Object
  • Object
show all
Defined in:
app/models/solidus_paypal_commerce_platform/state_guesser.rb

Instance Method Summary collapse

Constructor Details

#initialize(state_name, country) ⇒ StateGuesser

Returns a new instance of StateGuesser.



5
6
7
8
# File 'app/models/solidus_paypal_commerce_platform/state_guesser.rb', line 5

def initialize(state_name, country)
  @state_name = state_name
  @country = country
end

Instance Method Details

#guessObject



10
11
12
13
14
15
16
# File 'app/models/solidus_paypal_commerce_platform/state_guesser.rb', line 10

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