Class: Sandra::List
- Inherits:
-
Object
- Object
- Sandra::List
- Defined in:
- lib/sandra/list.rb
Instance Method Summary collapse
- #<<(obj) ⇒ Object
-
#initialize(name, type, owner) ⇒ List
constructor
A new instance of List.
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 |