Class: Spree::Store

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

Overview

Records store specific configuration such as store name and URL.

Spree::Store provides the foundational ActiveRecord model for recording information specific to your store such as its name, URL, and tax location. This model will provide the foundation upon which support for multiple stores hosted by a single Solidus implementation can be built.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default ⇒ Object



60
61
62
# File 'app/models/spree/store.rb', line 60

def self.default
  where(default: true).first || new
end

Instance Method Details

#address_attributes=(attributes) ⇒ Object



56
57
58
# File 'app/models/spree/store.rb', line 56

def address_attributes=(attributes)
  self.address = Spree::Address.immutable_merge(address, attributes)
end

#available_locales ⇒ Object



38
39
40
41
42
43
44
45
# File 'app/models/spree/store.rb', line 38

def available_locales
  locales = super
  if locales
    super.split(",").map(&:to_sym)
  else
    Spree.i18n_available_locales
  end
end

#available_locales=(locales) ⇒ Object



47
48
49
50
51
52
53
54
# File 'app/models/spree/store.rb', line 47

def available_locales=(locales)
  locales = locales.reject(&:blank?)
  if locales.empty?
    super(nil)
  else
    super(locales.join(","))
  end
end

#default_cart_tax_location ⇒ Object



64
65
66
67
# File 'app/models/spree/store.rb', line 64

def default_cart_tax_location
  @default_cart_tax_location ||=
    Spree::Tax::TaxLocation.new(country: Spree::Country.find_by(iso: cart_tax_country_iso))
end