Class: Spree::StoreSelector::Legacy

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/store_selector/legacy.rb

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Legacy

Returns a new instance of Legacy.



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

def initialize(request)
  @request = request
end

Instance Method Details

#storeSpree::Store

Chooses the current store based on a request. Checks request headers for HTTP_SPREE_STORE and falls back to looking up by the requesting server’s name.

Returns:



33
34
35
36
37
38
39
40
41
# File 'app/models/spree/store_selector/legacy.rb', line 33

def store
  current_store =
    if store_key
      Spree::Store.find_by(code: store_key) ||
        Store.where("url like ?", "%#{store_key}%").first
    end

  current_store || Spree::Store.default
end