Class: Relix::Query::Clause

Inherits:
Object
  • Object
show all
Defined in:
lib/relix/query.rb

Instance Method Summary collapse

Constructor Details

#initialize(redis, index) ⇒ Clause

Returns a new instance of Clause.



23
24
25
26
27
# File 'lib/relix/query.rb', line 23

def initialize(redis, index)
  @redis = redis
  @index = index
  @options = {}
end

Instance Method Details

#all(options = {}) ⇒ Object



34
35
36
37
# File 'lib/relix/query.rb', line 34

def all(options={})
  @all = true
  @options = options
end

#eq(value, options = {}) ⇒ Object



29
30
31
32
# File 'lib/relix/query.rb', line 29

def eq(value, options={})
  @value = @index.normalize(value)
  @options = options
end

#lookupObject



39
40
41
42
43
44
45
46
47
# File 'lib/relix/query.rb', line 39

def lookup
  if @options[:limit] == 0
    []
  elsif @all
    @index.all(@redis, @options)
  else
    @index.eq(@redis, @value, @options)
  end
end