Class: Sandra::List

Inherits:
Object
  • Object
show all
Defined in:
lib/sandra/list.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, type, owner) ⇒ List

Returns a new instance of List.



3
4
5
6
7
8
9
10
# File 'lib/sandra/list.rb', line 3

def initialize(name, type, owner)
  @column_family = name.to_s.camelize
  @type = type.to_s.constantize
  @owner = owner

  keys = @type.connection.get(@column_family, @owner.key).keys
  @elements = @type.multi_get(keys)
end

Instance Method Details

#<<(obj) ⇒ Object



12
13
14
15
16
17
# File 'lib/sandra/list.rb', line 12

def <<(obj)
  if obj.is_a?(@type)
    @elements << obj
    @type.connection.insert(@column_family, @owner.key, {obj.key => Time.now.to_s})
  end
end