Sha256: 0625e15a99bc54d4e52a2474ec5fabda317cd100ace264da3a4ad778935cc384

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Workarea
  decorate Search::StorefrontSearch::Response, with: :flow_io do
    decorated { attr_reader :experience }

    def initialize(options = {})
      @template = options.fetch(:template, 'show')
      @message = options[:message]
      @redirect = options[:redirect]

      @params = options.fetch(:params, {})
      @experience = @params[:experience]
      @params[:terms_facets] = terms_facets
      @params[:range_facets] = range_facets
      @params[:experience] = options[:experience]
      @original_params = @params.deep_dup

      @customization = options[:customization]
      @trace = []

      reset!(@params)
    end


    private

    def default_range_facets
      Search::Settings.current.range_facets
    end

    def range_facets
      return default_range_facets unless experience.present?

      localized_price_facets = Search::Settings.current.currency_localized_facets.fetch(experience.currency, {})

      default_range_facets
        .except("price")
        .merge("price-#{experience.key}" => localized_price_facets)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-flow_io-1.2.1 app/queries/workarea/search/storefront_search/response.decorator