Class: Relix::OrderedIndex

Inherits:
Index
  • Object
show all
Includes:
Ordering
Defined in:
lib/relix/indexes/ordered.rb

Defined Under Namespace

Classes: QueryClause

Instance Attribute Summary

Attributes inherited from Index

#model_name

Instance Method Summary collapse

Methods inherited from Index

#attribute_immutable?, compact_kind, #filter, #index?, kind, #name, #normalize, #query, #read, #read_normalized, #watch

Constructor Details

#initialize(set, base_name, accessor, options = {}) ⇒ OrderedIndex

Returns a new instance of OrderedIndex.



5
6
7
8
# File 'lib/relix/indexes/ordered.rb', line 5

def initialize(set, base_name, accessor, options={})
  super
  @order = accessor
end

Instance Method Details

#create_query_clause(redis) ⇒ Object



30
31
32
# File 'lib/relix/indexes/ordered.rb', line 30

def create_query_clause(redis)
  QueryClause.new(redis, self)
end

#deindex(r, pk, old_value) ⇒ Object



22
23
24
# File 'lib/relix/indexes/ordered.rb', line 22

def deindex(r, pk, old_value)
  r.zrem(sorted_set_name, pk)
end

#destroy_all(r) ⇒ Object



26
27
28
# File 'lib/relix/indexes/ordered.rb', line 26

def destroy_all(r)
  r.del(sorted_set_name)
end

#index(r, pk, object, value, old_value) ⇒ Object



18
19
20
# File 'lib/relix/indexes/ordered.rb', line 18

def index(r, pk, object, value, old_value)
  r.zadd(sorted_set_name, score(object, value), pk)
end

#sorted_set_nameObject



10
11
12
# File 'lib/relix/indexes/ordered.rb', line 10

def sorted_set_name
  name
end

#watch_keys(*values) ⇒ Object



14
15
16
# File 'lib/relix/indexes/ordered.rb', line 14

def watch_keys(*values)
  sorted_set_name
end