Class: SeapigSlaveObject
- Inherits:
-
SeapigObject
- Object
- Hash
- SeapigObject
- SeapigSlaveObject
- Defined in:
- lib/seapig-client-ruby/client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#received_at ⇒ Object
readonly
Returns the value of attribute received_at.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
Attributes inherited from SeapigObject
#destroyed, #id, #initialized, #version
Instance Method Summary collapse
-
#initialize(client, id, options) ⇒ SeapigSlaveObject
constructor
A new instance of SeapigSlaveObject.
- #invalidate ⇒ Object
- #onchange(&block) ⇒ Object
-
#patch(message) ⇒ Object
—– for SeapigClient.
- #validate ⇒ Object
Methods inherited from SeapigObject
#destroy, #matches, #ondestroy, #onstatuschange, #sanitized, #unlink
Constructor Details
#initialize(client, id, options) ⇒ SeapigSlaveObject
Returns a new instance of SeapigSlaveObject.
249 250 251 252 253 254 |
# File 'lib/seapig-client-ruby/client.rb', line 249 def initialize(client, id, ) super(client, id, ) @version = ([:version] or 0) @valid = false @received_at = nil end |
Instance Attribute Details
#received_at ⇒ Object (readonly)
Returns the value of attribute received_at.
246 247 248 |
# File 'lib/seapig-client-ruby/client.rb', line 246 def received_at @received_at end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
246 247 248 |
# File 'lib/seapig-client-ruby/client.rb', line 246 def valid @valid end |
Instance Method Details
#invalidate ⇒ Object
291 292 293 294 |
# File 'lib/seapig-client-ruby/client.rb', line 291 def invalidate @valid = false @onstatuschange_proc.call(self) if @onstatuschange_proc end |
#onchange(&block) ⇒ Object
257 258 259 260 |
# File 'lib/seapig-client-ruby/client.rb', line 257 def onchange(&block) @onchange_proc = block self end |
#patch(message) ⇒ Object
—– for SeapigClient
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/seapig-client-ruby/client.rb', line 264 def patch() @received_at = Time.new old_self = JSON.dump(self) if (not ['version-old']) or (['version-old'] == 0) or .has_key?('value') self.clear elsif not @version == ['version-old'] raise "Seapig lost some updates, this should never happen: "+[self, @version, ].inspect end if ['value'] self.merge!(['value']) else Hana::Patch.new(['patch']).apply(self) end @version = ['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 ⇒ Object
285 286 287 288 |
# File 'lib/seapig-client-ruby/client.rb', line 285 def validate @valid = @initialized @onstatuschange_proc.call(self) if @onstatuschange_proc end |