lib/deepstream/record.rb in deepstream-0.2.8 vs lib/deepstream/record.rb in deepstream-0.2.9
- old
+ new
@@ -2,20 +2,22 @@
require 'deepstream/constants'
require 'deepstream/helpers'
module Deepstream
class Record
- attr_reader :name, :data, :version
-
def initialize(client, name)
@client = client
@name = name
@data = {}
@version = nil
@client.send_message(TOPIC::RECORD, ACTION::CREATEORREAD, @name)
end
+ def get_name
+ @name
+ end
+
def inspect
"#{self.class} #{@name} #{@version} #{@data}"
end
def unsubscribe
@@ -25,10 +27,10 @@
def delete
@client.delete(@name)
end
def set(*args)
- if args.one?
+ if args.size == 1
raise(ArgumentError, "Record data must be a hash") unless args.first.is_a?(Hash)
@data = args.first
@client.send_message(TOPIC::RECORD, ACTION::UPDATE, @name, (@version += 1), @data.to_json) if @version
elsif args.size == 2
path, value = args