Sha256: 8190f7d0a85d60b82ac7ce888d83cb13b3b814f64462da52d64575f1aafa6f35
Contents?: true
Size: 1.04 KB
Versions: 49
Compression:
Stored size: 1.04 KB
Contents
module Sunspot module Query module Filter # # Express this filter as an :fq parameter; i.e., the boolean phrase, # maybe prefixed by local params. # def to_filter_query if tagged? then "{!tag=#{tag}}#{to_boolean_phrase}" else to_boolean_phrase end end # # Generate and return a tag that can be attached to this restriction, # for use with multiselect faceting. This needs to be unique, but doesn't # really need to be human-readable, so just generate a string based on the # hash of the boolean phrase. # def tag @tag ||= to_boolean_phrase.hash.abs.to_s(36) end private # # True if a tag has been generated for this filter (e.g., if it's been # excluded from a given facet). If a tag has not been generated at the # time that the filter query param is requested, then it is not necessary # to include a tag in the local params. # def tagged? !!@tag end end end end
Version data entries
49 entries across 49 versions & 11 rubygems