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.



258
259
260
261
# File 'lib/hakuban/manager.rb', line 258

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

Instance Method Details

#assigned?Boolean

Returns:

  • (Boolean)


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

def assigned?
  @contract.assigned?()
end

#assignementObject



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

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

#check_activeObject



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

def check_active
  assigned?
end

#data=(value) ⇒ Object



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

def data=(value)
  set_data(value)
end

#do_change(change) ⇒ Object



268
269
270
271
# File 'lib/hakuban/manager.rb', line 268

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

#run(handler) ⇒ Object



263
264
265
266
# File 'lib/hakuban/manager.rb', line 263

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

#set_data(value) ⇒ Object



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

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



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

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

#state=(state) ⇒ Object



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

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