Class: Rhoconnect::Model::ListProxy
Overview
Instance Method Summary
collapse
Methods inherited from FieldProxy
#initialize
Instance Method Details
#<<(v) ⇒ Object
Also known as:
push_tail
296
297
298
|
# File 'lib/rhoconnect/model.rb', line 296
def <<(v)
@redis.rpush @name, @marshal.dump(v)
end
|
#[](from, to = nil) ⇒ Object
Also known as:
range
313
314
315
316
317
318
319
|
# File 'lib/rhoconnect/model.rb', line 313
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
322
323
324
|
# File 'lib/rhoconnect/model.rb', line 322
def []=(index, v)
@redis.lset(@name, index, @marshal.dump(v))
end
|
#include?(v) ⇒ Boolean
327
328
329
|
# File 'lib/rhoconnect/model.rb', line 327
def include?(v)
@redis.exists(@name, @marshal.dump(v))
end
|
#pop_head ⇒ Object
309
310
311
|
# File 'lib/rhoconnect/model.rb', line 309
def pop_head
@marshal.load(@redis.lpop(@name))
end
|
#pop_tail ⇒ Object
305
306
307
|
# File 'lib/rhoconnect/model.rb', line 305
def pop_tail
@marshal.load(@redis.rpop(@name))
end
|
#push_head(v) ⇒ Object
301
302
303
|
# File 'lib/rhoconnect/model.rb', line 301
def push_head(v)
@redis.lpush @name, @marshal.dump(v)
end
|
#remove(count, v) ⇒ Object
331
332
333
|
# File 'lib/rhoconnect/model.rb', line 331
def remove(count, v)
@redis.lrem(@name, count, @marshal.dump(v))
end
|