Class: Spree::Country

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Class Method Details

.available(restrict_to_zone: Spree::Config[:checkout_zone]) ⇒ Object



22
23
24
25
26
27
28
# File 'core/app/models/spree/country.rb', line 22

def self.available(restrict_to_zone: Spree::Config[:checkout_zone])
  checkout_zone = Zone.find_by(name: restrict_to_zone)

  return checkout_zone.country_list if checkout_zone.try(:kind) == 'country'

  all
end

.defaultObject



13
14
15
16
17
18
19
20
# File 'core/app/models/spree/country.rb', line 13

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

Instance Method Details

#<=>(other) ⇒ Object



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

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

#to_sObject



34
35
36
# File 'core/app/models/spree/country.rb', line 34

def to_s
  name
end