Module: AttrSearchable::Arel::Visitors::PostgreSQL
- Defined in:
- lib/attr_searchable/arel/visitors.rb
Instance Method Summary collapse
- #visit_AttrSearchableGrammar_Attributes_Collection(o) ⇒ Object
- #visit_AttrSearchableGrammar_Nodes_And_Fulltext(o) ⇒ Object
- #visit_AttrSearchableGrammar_Nodes_FulltextExpression(o) ⇒ Object
- #visit_AttrSearchableGrammar_Nodes_MatchesFulltext(o) ⇒ Object
- #visit_AttrSearchableGrammar_Nodes_MatchesFulltextNot(o) ⇒ Object
- #visit_AttrSearchableGrammar_Nodes_Or_Fulltext(o) ⇒ Object
Instance Method Details
#visit_AttrSearchableGrammar_Attributes_Collection(o) ⇒ Object
163 164 165 |
# File 'lib/attr_searchable/arel/visitors.rb', line 163 def visit_AttrSearchableGrammar_Attributes_Collection(o, a) o.attributes.collect { |attribute| visit attribute.attribute, a }.join(" || ' ' || ") end |
#visit_AttrSearchableGrammar_Nodes_And_Fulltext(o) ⇒ Object
181 182 183 |
# File 'lib/attr_searchable/arel/visitors.rb', line 181 def visit_AttrSearchableGrammar_Nodes_And_Fulltext(o, a) o.nodes.collect { |node| "(#{visit node, a})" }.join(" & ") end |
#visit_AttrSearchableGrammar_Nodes_FulltextExpression(o) ⇒ Object
167 168 169 170 171 |
# File 'lib/attr_searchable/arel/visitors.rb', line 167 def visit_AttrSearchableGrammar_Nodes_FulltextExpression(o, a) dictionary = o.collection.[:dictionary] || "simple" "to_tsvector(#{visit dictionary, a}, #{visit o.collection, a}) @@ to_tsquery(#{visit dictionary, a}, #{visit visit(o.node, a), a})" end |
#visit_AttrSearchableGrammar_Nodes_MatchesFulltext(o) ⇒ Object
177 178 179 |
# File 'lib/attr_searchable/arel/visitors.rb', line 177 def visit_AttrSearchableGrammar_Nodes_MatchesFulltext(o, a) "'#{o.right.gsub /[\s&|!:'"]+/, " "}'" end |
#visit_AttrSearchableGrammar_Nodes_MatchesFulltextNot(o) ⇒ Object
173 174 175 |
# File 'lib/attr_searchable/arel/visitors.rb', line 173 def visit_AttrSearchableGrammar_Nodes_MatchesFulltextNot(o, a) "!'#{o.right}'" end |
#visit_AttrSearchableGrammar_Nodes_Or_Fulltext(o) ⇒ Object
185 186 187 |
# File 'lib/attr_searchable/arel/visitors.rb', line 185 def visit_AttrSearchableGrammar_Nodes_Or_Fulltext(o, a) o.nodes.collect { |node| "(#{visit node, a})" }.join(" | ") end |