Class: Percolate::Facet::TagFacet
- Defined in:
- lib/percolate/facet/tag_facet.rb
Overview
A facet for looking up entities based on collections of tags.
Defined Under Namespace
Classes: TagPoset
Instance Attribute Summary collapse
-
#poset_root ⇒ Object
readonly
Returns the value of attribute poset_root.
Instance Method Summary collapse
- #find(tags) ⇒ Object
-
#initialize(poset_root = nil) ⇒ TagFacet
constructor
A new instance of TagFacet.
- #merge(other) ⇒ Object
-
#rules=(rules_hash) ⇒ Object
Sets the tag lookup rules.
Constructor Details
#initialize(poset_root = nil) ⇒ TagFacet
Returns a new instance of TagFacet.
31 32 33 |
# File 'lib/percolate/facet/tag_facet.rb', line 31 def initialize(poset_root = nil) @poset_root = poset_root end |
Instance Attribute Details
#poset_root ⇒ Object (readonly)
Returns the value of attribute poset_root.
29 30 31 |
# File 'lib/percolate/facet/tag_facet.rb', line 29 def poset_root @poset_root end |
Instance Method Details
#find(tags) ⇒ Object
48 49 50 |
# File 'lib/percolate/facet/tag_facet.rb', line 48 def find() @poset_root.matches().sort end |
#merge(other) ⇒ Object
52 53 54 55 56 |
# File 'lib/percolate/facet/tag_facet.rb', line 52 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) ⇒ Object
Sets the tag lookup rules.
38 39 40 41 42 43 44 45 46 |
# File 'lib/percolate/facet/tag_facet.rb', line 38 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 |