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



23
24
25
# File 'app/models/spree/store_selector/legacy.rb', line 23

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:



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

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