Sha256: 57d621edc2783c40bd86698e549de5332a34b2c111b816bbaa29e52986432779
Contents?: true
Size: 852 Bytes
Versions: 2
Compression:
Stored size: 852 Bytes
Contents
require 'deepstream/record' module Deepstream class List < Record def initialize(*args) super @data = [] end def add(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) if data.is_a?(Array) @data.concat(data).uniq! set if @data.size > data.size end end def remove(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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
deepstream-0.3.2 | lib/deepstream/list.rb |
deepstream-0.3.1 | lib/deepstream/list.rb |