Sha256: 1fba469da87c65dde69a02a9ad8de70a9a7f5b286127032dea39b925ace6e24c
Contents?: true
Size: 892 Bytes
Versions: 62
Compression:
Stored size: 892 Bytes
Contents
module Workarea module Search # TODO remove in v4, unused now class FacetMatches def initialize(params, facets) @params = params @facets = facets end def query @query ||= @params[:q].try(:strip).to_s end def matches @matches ||= @facets.reduce({}) do |memo, facet| facet.results.keys.each do |value| if query =~ /(^|\s+)#{Regexp.quote(value.to_s)}(\s+|$)/i memo[facet.system_name] ||= [] memo[facet.system_name] << value end end memo end end def params return @params unless matches.keys.one? @_params ||= matches.reduce(@params) do |memo, tuple| name, values = *tuple memo[name] ||= [] memo[name].push(*values) memo end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems