lib/hari/keys/list.rb in hari-0.0.4 vs lib/hari/keys/list.rb in hari-0.0.5
- old
+ new
@@ -31,15 +31,15 @@
def last
self[-1]
end
def []=(index, member)
- Hari.redis.lset key, index, member
+ Hari.redis.lset key, index, serialize(member)
end
def range(start = 0, stop = -1)
- Hari.redis.lrange key, start, stop
+ desserialize Hari.redis.lrange(key, start, stop)
end
alias :members :range
alias :to_a :range
@@ -50,11 +50,11 @@
def to(index)
range 0, index
end
def at(index)
- Hari.redis.lindex key, index
+ desserialize Hari.redis.lindex(key, index)
end
alias :index :at
def trim(start, stop)
@@ -79,24 +79,26 @@
def many?
count > 1
end
def include?(member)
- range.include? member
+ range.include? serialize(member)
end
alias :member? :include?
def push(*members)
- Hari.redis.rpush key, members
+ return if Array(members).empty?
+
+ Hari.redis.rpush key, serialize(members)
end
alias :rpush :push
alias :add :push
def lpush(*members)
- Hari.redis.lpush key, members
+ Hari.redis.lpush key, serialize(members)
end
def <<(member)
push member
end
@@ -114,16 +116,16 @@
def delete(member, count = 0)
Hari.redis.lrem key, count, member
end
def pop
- Hari.redis.rpop key
+ desserialize Hari.redis.rpop(key)
end
alias :rpop :pop
def shift
- Hari.redis.lpop key
+ desserialize Hari.redis.lpop(key)
end
alias :lpop :shift
end