lib/deepstream/record.rb in deepstream-0.3.2 vs lib/deepstream/record.rb in deepstream-1.0.0

- old
+ new

@@ -7,14 +7,32 @@ def initialize(client, name) @client = client @name = name @data = {} @version = nil + @is_reinitializing = false + @data_cache = {} @client.send_message(TOPIC::RECORD, ACTION::CREATEORREAD, @name) end - def get_name - @name + def reset_version + @version = 0 + end + + def is_reinitializing? + @is_reinitializing + end + + def start_reinitializing + @is_reinitializing = true + @data_cache = @data + @client.send_message(TOPIC::RECORD, ACTION::CREATEORREAD, @name, priority: true) + end + + def end_reinitializing + reset_version + set(@data_cache) + @is_reinitializing = false end def inspect "#{self.class} #{@name} #{@version} #{@data}" end