Class: SolidusPaypalCommercePlatform::StateGuesser
- Inherits:
-
Object
- Object
- SolidusPaypalCommercePlatform::StateGuesser
- Defined in:
- app/models/solidus_paypal_commerce_platform/state_guesser.rb
Instance Method Summary collapse
- #guess ⇒ Object
-
#initialize(state_name, country) ⇒ StateGuesser
constructor
A new instance of StateGuesser.
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
#guess ⇒ Object
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 |