Sha256: 46bf362d9ea6c72c30ff349ee3f086f70ee3ee7ec097dbdee558113bc849aa14

Contents?: true

Size: 835 Bytes

Versions: 20

Compression:

Stored size: 835 Bytes

Contents

# Default class for deciding what the current store is, given an HTTP request
# This is an extension point used in Spree::Core::ControllerHelpers::Store
# Custom versions of this class must respond to a store instance method
module Spree
  module Core
    class CurrentStore
      def initialize(request)
        @request = request
      end

      # 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.
      # @return [Spree::Store]
      def store
        if store_key
          Spree::Store.current(store_key)
        else
          Spree::Store.default
        end
      end

      private

      def store_key
        @request.headers['HTTP_SPREE_STORE'] || @request.env['SERVER_NAME']
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
solidus_core-2.2.2 lib/spree/core/current_store.rb
solidus_core-2.1.1 lib/spree/core/current_store.rb
solidus_core-2.0.3 lib/spree/core/current_store.rb
solidus_core-1.4.2 lib/spree/core/current_store.rb
solidus_core-2.0.2 lib/spree/core/current_store.rb
solidus_core-1.4.1 lib/spree/core/current_store.rb
solidus_core-2.2.1 lib/spree/core/current_store.rb
solidus_core-2.2.0 lib/spree/core/current_store.rb
solidus_core-2.2.0.rc1 lib/spree/core/current_store.rb
solidus_core-2.2.0.beta1 lib/spree/core/current_store.rb
solidus_core-2.1.0 lib/spree/core/current_store.rb
solidus_core-2.1.0.rc1 lib/spree/core/current_store.rb
solidus_core-2.0.1 lib/spree/core/current_store.rb
solidus_core-2.1.0.beta1 lib/spree/core/current_store.rb
solidus_core-2.0.0 lib/spree/core/current_store.rb
solidus_core-1.4.0 lib/spree/core/current_store.rb
solidus_core-2.0.0.rc1 lib/spree/core/current_store.rb
solidus_core-1.4.0.rc1 lib/spree/core/current_store.rb
solidus_core-2.0.0.beta1 lib/spree/core/current_store.rb
solidus_core-1.4.0.beta1 lib/spree/core/current_store.rb