Class: Deepstream::List

Inherits:
Record
  • Object
show all
Defined in:
lib/deepstream.rb

Instance Method Summary collapse

Methods inherited from Record

#_patch, #_update, #get_name, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Deepstream::Record

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Deepstream::Record

Instance Method Details

#add(record_name) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/deepstream.rb', line 57

def add(record_name)
  if @data.is_a?(Array)
    @data.push record_name unless @data.include? record_name
  else
    @data = [record_name]
  end
  @client._write('R', 'U', @name, (@version += 1), JSON.dump(@data))
  @data
end

#allObject



73
74
75
# File 'lib/deepstream.rb', line 73

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

#keysObject



77
78
79
# File 'lib/deepstream.rb', line 77

def keys
  @data
end

#remove(record_name) ⇒ Object



67
68
69
70
71
# File 'lib/deepstream.rb', line 67

def remove(record_name)
  @data.delete_if { |x| x == record_name }
  @client._write('R', 'U', @name, (@version += 1), JSON.dump(@data))
  @data
end

#set(*args) ⇒ Object



81
82
83
# File 'lib/deepstream.rb', line 81

def set(*args)
  fail 'cannot use set on a list'
end