Class: Deepstream::List
Instance Method Summary
collapse
Methods inherited from Record
#delete, #inspect, #is_reinitializing?, #method_missing, #patch, #reset_version, #start_reinitializing, #unsubscribe, #update
Constructor Details
#initialize(*args) ⇒ List
Returns a new instance of List.
5
6
7
8
|
# File 'lib/deepstream/list.rb', line 5
def initialize(*args)
super
@data = []
end
|
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
10
11
12
13
14
15
16
17
|
# File 'lib/deepstream/list.rb', line 10
def add(record_name)
unless @data.include?(record_name)
@data << record_name
set
end
rescue => e
@client.on_exception(e)
end
|
#all ⇒ Object
36
37
38
|
# File 'lib/deepstream/list.rb', line 36
def all
@data.map { |record_name| @client.get(record_name) }
end
|
#end_reinitializing ⇒ Object
40
41
42
43
44
|
# File 'lib/deepstream/list.rb', line 40
def end_reinitializing
reset_version
set
@is_reinitializing = false
end
|
#keys ⇒ Object
32
33
34
|
# File 'lib/deepstream/list.rb', line 32
def keys
@data
end
|
#read(version, data) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/deepstream/list.rb', line 19
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
|
#remove(record_name) ⇒ Object
28
29
30
|
# File 'lib/deepstream/list.rb', line 28
def remove(record_name)
set if @data.delete(record_name)
end
|