Class: Spree::StoreSelector::Legacy
- Inherits:
-
Object
- Object
- Spree::StoreSelector::Legacy
- Defined in:
- app/models/spree/store_selector/legacy.rb
Instance Method Summary collapse
-
#initialize(request) ⇒ Legacy
constructor
A new instance of Legacy.
-
#store ⇒ Spree::Store
Chooses the current store based on a request.
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
#store ⇒ Spree::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.
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 |