Class: Redis::Model::ListProxy
Overview
Instance Method Summary
collapse
Methods inherited from FieldProxy
#initialize, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Redis::Model::FieldProxy
Instance Method Details
#<<(v) ⇒ Object
Also known as:
push_tail
253
254
255
|
# File 'lib/redis/model.rb', line 253
def <<(v)
@redis.rpush @name, @marshal.dump(v)
end
|
#[](from, to = nil) ⇒ Object
Also known as:
range
270
271
272
273
274
275
276
|
# File 'lib/redis/model.rb', line 270
def [](from, to = nil)
if to.nil?
@marshal.load(@redis.lindex(@name, from))
else
@redis.lrange(@name, from, to).map! { |v| @marshal.load(v) }
end
end
|
#[]=(index, v) ⇒ Object
Also known as:
set
279
280
281
|
# File 'lib/redis/model.rb', line 279
def []=(index, v)
@redis.lset(@name, index, @marshal.dump(v))
end
|
#include?(v) ⇒ Boolean
284
285
286
|
# File 'lib/redis/model.rb', line 284
def include?(v)
@redis.exists(@name, @marshal.dump(v))
end
|
#length ⇒ Object
292
293
294
|
# File 'lib/redis/model.rb', line 292
def length
@redis.llen(@name)
end
|
#pop_head ⇒ Object
266
267
268
|
# File 'lib/redis/model.rb', line 266
def pop_head
@marshal.load(@redis.lpop(@name))
end
|
#pop_tail ⇒ Object
262
263
264
|
# File 'lib/redis/model.rb', line 262
def pop_tail
@marshal.load(@redis.rpop(@name))
end
|
#push_head(v) ⇒ Object
258
259
260
|
# File 'lib/redis/model.rb', line 258
def push_head(v)
@redis.lpush @name, @marshal.dump(v)
end
|
#remove(count, v) ⇒ Object
288
289
290
|
# File 'lib/redis/model.rb', line 288
def remove(count, v)
@redis.lrem(@name, count, @marshal.dump(v))
end
|
#to_s ⇒ Object
300
301
302
|
# File 'lib/redis/model.rb', line 300
def to_s
range(0, 100).join(', ')
end
|
#trim(from, to) ⇒ Object
296
297
298
|
# File 'lib/redis/model.rb', line 296
def trim(from, to)
@redis.ltrim(@name, from, to)
end
|