class SeapigSlaveObject
Attributes
received_at[R]
valid[R]
Public Class Methods
new(client, id, options)
click to toggle source
Calls superclass method
SeapigObject::new
# File lib/seapig-client-ruby/client.rb, line 249 def initialize(client, id, options) super(client, id, options) @version = (options[:version] or 0) @valid = false @received_at = nil end
Public Instance Methods
invalidate()
click to toggle source
# File lib/seapig-client-ruby/client.rb, line 291 def invalidate @valid = false @onstatuschange_proc.call(self) if @onstatuschange_proc end
onchange(&block)
click to toggle source
# File lib/seapig-client-ruby/client.rb, line 257 def onchange(&block) @onchange_proc = block self end
patch(message)
click to toggle source
—– for SeapigClient
# File lib/seapig-client-ruby/client.rb, line 264 def patch(message) @received_at = Time.new old_self = JSON.dump(self) if (not message['version-old']) or (message['version-old'] == 0) or message.has_key?('value') self.clear elsif not @version == message['version-old'] raise "Seapig lost some updates, this should never happen: "+[self, @version, message].inspect end if message['value'] self.merge!(message['value']) else Hana::Patch.new(message['patch']).apply(self) end @version = message['version-new'] @valid = true @initialized = true @onstatuschange_proc.call(self) if @onstatuschange_proc @onchange_proc.call(self) if @onchange_proc and old_self != JSON.dump(self) end
validate()
click to toggle source
# File lib/seapig-client-ruby/client.rb, line 285 def validate @valid = @initialized @onstatuschange_proc.call(self) if @onstatuschange_proc end