Class: Spree::Country

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/country.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Class Method Details

.defaultObject



16
17
18
19
20
21
22
23
# File 'app/models/spree/country.rb', line 16

def self.default
  if Spree::Config.default_country_id
    Spree::Deprecation.warn("Setting your default country via its ID is deprecated. Please set your default country via the `default_country_iso` setting.", caller)
    find_by(id: Spree::Config.default_country_id) || find_by!(iso: Spree::Config.default_country_iso)
  else
    find_by!(iso: Spree::Config.default_country_iso)
  end
end

.states_required_by_country_idObject



9
10
11
12
13
14
# File 'app/models/spree/country.rb', line 9

def self.states_required_by_country_id
  Spree::Deprecation.warn "Spree::Country.states_required_by_country_id is deprecated and will be removed from future releases, Implement it yourself.", caller
  states_required = Hash.new(true)
  all.each { |country| states_required[country.id.to_s] = country.states_required }
  states_required
end

Instance Method Details

#<=>(other) ⇒ Object



25
26
27
# File 'app/models/spree/country.rb', line 25

def <=>(other)
  name <=> other.name
end

#to_sObject



29
30
31
# File 'app/models/spree/country.rb', line 29

def to_s
  name
end