Class: Deepstream::List
Instance Method Summary
collapse
Methods inherited from Record
#_patch, #_update, #initialize, #method_missing
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
53
54
55
56
57
58
59
60
61
|
# File 'lib/deepstream.rb', line 53
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
|
#all ⇒ Object
69
70
71
|
# File 'lib/deepstream.rb', line 69
def all
@data.map { |x| @client.get(x) }
end
|
#keys ⇒ Object
73
74
75
|
# File 'lib/deepstream.rb', line 73
def keys
@data
end
|
#remove(record_name) ⇒ Object
63
64
65
66
67
|
# File 'lib/deepstream.rb', line 63
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
77
78
79
|
# File 'lib/deepstream.rb', line 77
def set(*args)
fail 'cannot use set on a list'
end
|