class Percolate::Facet::TagFacet
A facet for looking up entities based on collections of tags.
Attributes
poset_root[R]
Public Class Methods
new(poset_root = nil)
click to toggle source
# File lib/percolate/facet/tag_facet.rb, line 30 def initialize(poset_root = nil) @poset_root = poset_root end
Public Instance Methods
find(tags)
click to toggle source
# File lib/percolate/facet/tag_facet.rb, line 47 def find(tags) @poset_root.matches(tags).sort end
merge(other)
click to toggle source
# File lib/percolate/facet/tag_facet.rb, line 51 def merge(other) raise ArgumentError, "Please provide another #{self.class}" if !other.is_a?(TagFacet) TagFacet.new(@poset_root.merge(other.poset_root)) end
rules=(rules_hash)
click to toggle source
Sets the tag lookup rules.
@param rules_hash [Hash] the lookup rules.
# File lib/percolate/facet/tag_facet.rb, line 37 def rules=(rules_hash) @poset_root = TagPoset.new rules_hash.each do |rule_hash| @poset_root.insert(rule_hash["tags"], rule_hash["value"]) end rules_hash end