Class: Ambition::Adapters::AmbitiousSphinx::Select
- Defined in:
- lib/ambition/adapters/ambitious_sphinx/select.rb
Overview
Select is responsible for taking pure Ruby, and mangling it until it resembles the syntax that Ultrasphinx uses.
Instance Method Summary collapse
-
#<(left, right) ⇒ Object
Not supported by Sphinx.
-
#<=(left, right) ⇒ Object
Not supported by Sphinx.
-
#==(left, right) ⇒ Object
Sphinx doesn’t support equality.
-
#=~(left, right) ⇒ Object
Handles generating an Ultrasphinx query for code like:.
-
#>(left, right) ⇒ Object
Not supported by Sphinx.
-
#>=(left, right) ⇒ Object
Not supported by Sphinx.
-
#both(left, right) ⇒ Object
Handles generating an Ultrasphinx query for code like:.
-
#call(method) ⇒ Object
Handles method calls, like.
-
#chained_call(*methods) ⇒ Object
Should we be supporting chained calls like:.
-
#either(left, right) ⇒ Object
Handles generating an Ultrasphinx query for code like:.
-
#include?(left, right) ⇒ Boolean
Not supported by Sphinx.
-
#not_equal(left, right) ⇒ Object
Sphinx doesn’t support inequality.
-
#not_regexp(left, right) ⇒ Object
Handles generating an Ultrasphinx query for code like:.
Methods inherited from Base
#has_field?, #has_operator?, #needs_quoting?, #quotify
Instance Method Details
#<(left, right) ⇒ Object
Not supported by Sphinx. If you need this kind of comparison, you probably should be using ambitious-activerecord.
78 79 80 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 78 def <(left, right) raise "Not applicable to sphinx." end |
#<=(left, right) ⇒ Object
Not supported by Sphinx. If you need this kind of comparison, you probably should be using ambitious-activerecord.
96 97 98 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 96 def <=(left, right) raise "Not applicable to sphinx." end |
#==(left, right) ⇒ Object
Sphinx doesn’t support equality.
40 41 42 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 40 def ==(left, right) raise "Not applicable to sphinx." end |
#=~(left, right) ⇒ Object
Handles generating an Ultrasphinx query for code like:
u.name =~ 'bob'
Some cavaets:
* left hand side _must_ be a field, like u.name
* right hand side _must not_ be a regular expression. Pattern matching is generally not
supported by full text search engines
57 58 59 60 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 57 def =~(left, right) raise if right.is_a? Regexp "#{left}#{quotify right}" end |
#>(left, right) ⇒ Object
Not supported by Sphinx. If you need this kind of comparison, you probably should be using ambitious-activerecord.
84 85 86 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 84 def >(left, right) raise "Not applicable to sphinx." end |
#>=(left, right) ⇒ Object
Not supported by Sphinx. If you need this kind of comparison, you probably should be using ambitious-activerecord.
90 91 92 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 90 def >=(left, right) raise "Not applicable to sphinx." end |
#both(left, right) ⇒ Object
Handles generating an Ultrasphinx query for code like:
'foo' && 'bar'
28 29 30 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 28 def both(left, right) "#{quotify left} AND #{quotify right}" end |
#call(method) ⇒ Object
Handles method calls, like
u.name
10 11 12 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 10 def call(method) "#{method.to_s}:" end |
#chained_call(*methods) ⇒ Object
Should we be supporting chained calls like:
u.name.downcase
?
I don’t think Sphinx would be able to handle this.
21 22 23 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 21 def chained_call(*methods) raise "Not implemented yet." end |
#either(left, right) ⇒ Object
Handles generating an Ultrasphinx query for code like:
'foo' || 'bar'
35 36 37 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 35 def either(left, right) "#{quotify left} OR #{quotify right}" end |
#include?(left, right) ⇒ Boolean
Not supported by Sphinx. If you need this kind of comparison, you probably should be using ambitious-activerecord.
102 103 104 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 102 def include?(left, right) raise "Not applicable to sphinx." end |
#not_equal(left, right) ⇒ Object
Sphinx doesn’t support inequality.
45 46 47 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 45 def not_equal(left, right) raise "Not applicable to sphinx." end |
#not_regexp(left, right) ⇒ Object
Handles generating an Ultrasphinx query for code like:
u.name !~ 'bob'
Some cavaets:
* left hand side _must_ be a field, like u.name
* right hand side _must not_ be a regular expression. Pattern matching is generally not
supported by full text search engines
70 71 72 73 74 |
# File 'lib/ambition/adapters/ambitious_sphinx/select.rb', line 70 def not_regexp(left, right) # could be DRYer, but this is more readable than: "NOT #{self.=~(left,right)}" raise if right.is_a? Regexp "NOT #{left}#{quotify right}" end |