lib/deepstream/list.rb in deepstream-0.2.7 vs lib/deepstream/list.rb in deepstream-0.2.8

- old
+ new

@@ -6,11 +6,16 @@ super @data = [] end def add(record_name) - set(@data << record_name) unless @data.include?(record_name) + unless @data.include?(record_name) + @data << record_name + set + end + rescue => e + @client.on_exception(e) end def read(version, data) @version = version.to_i data = JSON.parse(data) @@ -19,17 +24,23 @@ set(@data) if @data.size > data.size end end def remove(record_name) - set(@data) if @data.delete(record_name) + set if @data.delete(record_name) end def keys @data end def all @data.map { |record_name| @client.get(record_name) } + end + + private + + def set + @client.send_message(TOPIC::RECORD, ACTION::UPDATE, @name, (@version += 1), @data.to_json) if @version end end end