Class: Rhoconnect::StoreOrm::ListProxy

Inherits:
FieldProxy
  • Object
show all
Defined in:
lib/rhoconnect/store_orm.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from FieldProxy

#initialize

Constructor Details

This class inherits a constructor from Rhoconnect::StoreOrm::FieldProxy

Instance Method Details

#<<(v) ⇒ Object Also known as: push_tail



285
286
287
# File 'lib/rhoconnect/store_orm.rb', line 285

def <<(v)
  @store_db.rpush @name, @marshal.dump(v)
end

#[](from, to = nil) ⇒ Object Also known as: range



302
303
304
305
306
307
308
# File 'lib/rhoconnect/store_orm.rb', line 302

def [](from, to = nil)
  if to.nil?
    @marshal.load(@store_db.lindex(@name, from))
  else
    @store_db.lrange(@name, from, to).map! { |v| @marshal.load(v) }
  end
end

#[]=(index, v) ⇒ Object Also known as: set



311
312
313
# File 'lib/rhoconnect/store_orm.rb', line 311

def []=(index, v)
  @store_db.lset(@name, index, @marshal.dump(v))
end

#include?(v) ⇒ Boolean

Returns:

  • (Boolean)


316
317
318
# File 'lib/rhoconnect/store_orm.rb', line 316

def include?(v)
  @store_db.exists(@name, @marshal.dump(v))
end

#pop_headObject



298
299
300
# File 'lib/rhoconnect/store_orm.rb', line 298

def pop_head
  @marshal.load(@store_db.lpop(@name))
end

#pop_tailObject



294
295
296
# File 'lib/rhoconnect/store_orm.rb', line 294

def pop_tail
  @marshal.load(@store_db.rpop(@name))
end

#push_head(v) ⇒ Object



290
291
292
# File 'lib/rhoconnect/store_orm.rb', line 290

def push_head(v)
  @store_db.lpush @name, @marshal.dump(v)
end

#remove(count, v) ⇒ Object



320
321
322
# File 'lib/rhoconnect/store_orm.rb', line 320

def remove(count, v)
  @store_db.lrem(@name, count, @marshal.dump(v))
end