Class: Hakuban::ObjectExpose::ManagedObject

Inherits:
ManagedObjectBase show all
Defined in:
lib/hakuban/manager.rb

Instance Attribute Summary

Attributes inherited from ManagedObjectBase

#async, #current_delay_index, #descriptor, #earliest_next_run, #last_exception_at, #running

Instance Method Summary collapse

Methods inherited from ManagedObjectBase

#change, #next_change, #next_event, #stop

Constructor Details

#initialize(contract, descriptor) ⇒ ManagedObject

Returns a new instance of ManagedObject.



261
262
263
264
# File 'lib/hakuban/manager.rb', line 261

def initialize(contract, descriptor)
  super(contract, descriptor)
  @assignment = contract.assignment
end

Instance Method Details

#assigned?Boolean

Returns:

  • (Boolean)


280
281
282
# File 'lib/hakuban/manager.rb', line 280

def assigned?
  @contract.assigned?()
end

#assignementObject



276
277
278
# File 'lib/hakuban/manager.rb', line 276

def assignement
  @assignment = @contract.assignment()
end

#check_activeObject



302
303
304
# File 'lib/hakuban/manager.rb', line 302

def check_active
  assigned?
end

#data=(value) ⇒ Object



298
299
300
# File 'lib/hakuban/manager.rb', line 298

def data=(value)
  set_data(value)
end

#do_change(change) ⇒ Object



271
272
273
274
# File 'lib/hakuban/manager.rb', line 271

def do_change(change)
  @assignment = @contract.assignment
  super(change)
end

#run(handler) ⇒ Object



266
267
268
269
# File 'lib/hakuban/manager.rb', line 266

def run(handler)
  super
  @contract.desynchronize(@assignment)
end

#set_data(value) ⇒ Object



293
294
295
296
# File 'lib/hakuban/manager.rb', line 293

def set_data(value)
  timestamp = Time.new.to_f
  set_state([1, timestamp.floor, ((timestamp - timestamp.floor)*1000000000).floor, 0],value)
end

#set_state(*state, **kwargs) ⇒ Object



284
285
286
287
# File 'lib/hakuban/manager.rb', line 284

def set_state(*state, **kwargs)
  kwargs[:assignment] ||= @assignment
  @contract.set_object_state(*state, **kwargs)
end

#state=(state) ⇒ Object



289
290
291
# File 'lib/hakuban/manager.rb', line 289

def state=(state)
  set_state(*state)
end