Class: Relix::Keyer::Legacy

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

Instance Method Summary collapse

Constructor Details

#initialize(klass, options) ⇒ Legacy

Returns a new instance of Legacy.



17
18
19
# File 'lib/relix/keyer.rb', line 17

def initialize(klass, options)
  @prefix = klass.name
end

Instance Method Details

#component(name, component) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/relix/keyer.rb', line 34

def component(name, component)
  if name =~ /^Relix::UniqueIndex:/
    component = case component
    when 'lookup'
      'hash'
    when 'ordering'
      'zset'
    else
      component
    end
  end

  "#{name}:#{component}"
end

#index(index, name) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/relix/keyer.rb', line 25

def index(index, name)
  case index
  when PrimaryKeyIndex
    "#{index.class.name}:#{index.model_name}:primary_key"
  else
    "#{index.class.name}:#{index.model_name}:#{name}"
  end
end

#values(pk, klass) ⇒ Object



21
22
23
# File 'lib/relix/keyer.rb', line 21

def values(pk, klass)
  "#{klass.name}:current_values:#{pk}"
end