Sha256: bc5db1ea8d7d28496d286afa68f6182789e22d949a89d3647984d6b5fa6828f0
Contents?: true
Size: 1.18 KB
Versions: 14
Compression:
Stored size: 1.18 KB
Contents
module Workarea module Search class StorefrontSearch attr_reader :params def initialize(params) @params = params.with_indifferent_access.except(:per_page) @used_middleware = [] end def customization @customization ||= Customization.active.find_by_query( params[:q].try(:strip).to_s ) end def response @response ||= begin result = StorefrontSearch::Response.new( params: params, customization: customization ) chain = create_middleware_chain traverse_chain = lambda do unless chain.empty? piece = chain.shift @used_middleware << piece piece.call(result, &traverse_chain) end end traverse_chain.call result end end def used_middleware response @used_middleware end def create_middleware_chain Workarea.config.storefront_search_middleware.map do |class_name| class_name.constantize.new(params, customization) end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems