class Relix::PrimaryKeyIndex

Public Class Methods

new(set, base_name, accessor, options={}) click to toggle source
Calls superclass method Relix::Index::new
# File lib/relix/indexes/primary_key.rb, line 5
def initialize(set, base_name, accessor, options={})
  options[:immutable_attribute] = true unless options.has_key?(:immutable_attribute)
  super
end

Public Instance Methods

all(r, options={}) click to toggle source
# File lib/relix/indexes/primary_key.rb, line 30
def all(r, options={})
  r.zrange(name, *range_from_options(r, options))
end
deindex(r, pk, old_value) click to toggle source
# File lib/relix/indexes/primary_key.rb, line 26
def deindex(r, pk, old_value)
  r.zrem(name, pk)
end
eq(r, value, options) click to toggle source
# File lib/relix/indexes/primary_key.rb, line 34
def eq(r, value, options)
  [value]
end
filter(r, pk, object, value) click to toggle source
# File lib/relix/indexes/primary_key.rb, line 14
def filter(r, pk, object, value)
  !r.zscore(name, value)
end
index(r, pk, object, value, old_value, rank) click to toggle source
# File lib/relix/indexes/primary_key.rb, line 22
def index(r, pk, object, value, old_value, rank)
  r.zadd(name, rank, pk)
end
position(r, pk, value) click to toggle source
# File lib/relix/indexes/primary_key.rb, line 38
def position(r, pk, value)
  position = r.zrank(name, pk)
  raise MissingIndexValueError, "Cannot find key #{pk} in index" unless position
  position
end
query(r, value) click to toggle source
# File lib/relix/indexes/primary_key.rb, line 18
def query(r, value)
  r.zcard(name)
end
watch_keys(*values) click to toggle source
# File lib/relix/indexes/primary_key.rb, line 10
def watch_keys(*values)
  name
end