Class: Spree::State
- Inherits:
-
Base
- Object
- Base
- Spree::State
- Defined in:
- app/models/spree/state.rb
Class Method Summary collapse
-
.states_group_by_country_id ⇒ Object
table of { country.id => [ state.id , state.name ] }, arrays sorted by name blank is added elsewhere, if needed.
Instance Method Summary collapse
Class Method Details
.states_group_by_country_id ⇒ Object
table of { country.id => [ state.id , state.name ] }, arrays sorted by name blank is added elsewhere, if needed
23 24 25 26 27 28 29 |
# File 'app/models/spree/state.rb', line 23 def self.states_group_by_country_id state_info = Hash.new { |hash, key| hash[key] = [] } order(:name).each { |state| state_info[state.country_id.to_s].push [state.id, state.name] } state_info end |
Instance Method Details
#<=>(other) ⇒ Object
31 32 33 |
# File 'app/models/spree/state.rb', line 31 def <=>(other) name <=> other.name end |
#state_with_country ⇒ Object
39 40 41 42 43 |
# File 'app/models/spree/state.rb', line 39 def state_with_country Rails.cache.fetch("#{cache_key_with_version}/state_with_country") do "#{name} (#{country})" end end |
#to_s ⇒ Object
35 36 37 |
# File 'app/models/spree/state.rb', line 35 def to_s name end |