Sha256: 6c26251934e36da62d25c5e032756d19cb2b6b6b8cc04d27cf16c73abf8f8c50

Contents?: true

Size: 662 Bytes

Versions: 6

Compression:

Stored size: 662 Bytes

Contents

require 'deepstream/record'

module Deepstream
  class List < Record
    def initialize(*args)
      super
      @data = []
    end

    def add(record_name)
      set(@data.length.to_s, record_name) unless @data.include?(record_name)
    end

    def read(version, data)
      @version = version.to_i
      data = JSON.parse(data)
      if data.is_a?(Array)
        @data.concat(data).uniq!
        set(@data) if @data.size > data.size
      end
    end

    def remove(record_name)
      set(@data) if @data.delete(record_name)
    end

    def keys
      @data
    end

    def all
      @data.map { |record_name| @client.get(record_name) }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
deepstream-0.2.6 lib/deepstream/list.rb
deepstream-0.2.5 lib/deepstream/list.rb
deepstream-0.2.4 lib/deepstream/list.rb
deepstream-0.2.3 lib/deepstream/list.rb
deepstream-0.2.2 lib/deepstream/list.rb
deepstream-0.2.1 lib/deepstream/list.rb