Class: SeapigWildcardObject
- Inherits:
-
SeapigObject
- Object
- Hash
- SeapigObject
- SeapigWildcardObject
- Defined in:
- lib/seapig/client.rb
Instance Attribute Summary
Attributes inherited from SeapigObject
#destroyed, #object_id, #parent, #received_at, #stall, #version, #version_requested
Instance Method Summary collapse
- #destroy(message) ⇒ Object
-
#initialize(*args) ⇒ SeapigWildcardObject
constructor
A new instance of SeapigWildcardObject.
- #patch(message) ⇒ Object
- #produce(object_id, version) ⇒ Object
Methods inherited from SeapigObject
#matches?, #onchange, #onproduce, #reset, #sanitized, #send, #set, #upload, #valid?
Constructor Details
#initialize(*args) ⇒ SeapigWildcardObject
Returns a new instance of SeapigWildcardObject.
295 296 297 298 |
# File 'lib/seapig/client.rb', line 295 def initialize(*args) super(*args) @children = ObjectSpace::WeakMap.new end |
Instance Method Details
#destroy(message) ⇒ Object
308 309 310 311 312 313 |
# File 'lib/seapig/client.rb', line 308 def destroy() if destroyed = self.delete(['id']) destroyed.destroyed = true @onchange_proc.call(destroyed) if @onchange_proc end end |
#patch(message) ⇒ Object
301 302 303 304 305 |
# File 'lib/seapig/client.rb', line 301 def patch() self[['id']] ||= SeapigObject.new(@server, ['id'], self) self[['id']].patch() @onchange_proc.call(self[['id']]) if @onchange_proc end |
#produce(object_id, version) ⇒ Object
316 317 318 319 320 321 322 323 324 325 |
# File 'lib/seapig/client.rb', line 316 def produce(object_id, version) key = @children.keys.find { |key| key == object_id } child = (@children[(key or object_id)] ||= SeapigObject.new(@server, object_id, self)) child.version_requested = version if @onproduce_proc @onproduce_proc.call(child) else child.upload(0,{},object_id) end end |