Module: Redis::Actions::Finding::ClassMethods

Defined in:
lib/redis/actions/finding.rb

Instance Method Summary collapse

Instance Method Details

#allObject



20
21
22
23
24
# File 'lib/redis/actions/finding.rb', line 20

def all
  connection.hgetall(File.join(model_name, "ids")).collect do |id|
    find(id.first)
  end
end

#find(id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/redis/actions/finding.rb', line 7

def find(id)
  data = connection.get(id)
  if data
    klass_name = id.split(/\//)[0]
    klass = (klass_name.camelize.constantize rescue self)
    instance = klass.new(serializer.load(data))
    instance.set_unchanged!
    instance
  else
    nil
  end
end