class Hakuban::ObjectManager
TODO: replace this mess (<Hash, dynamic mixins) with some “deref”
Attributes
contract[R]
objects[R]
Public Instance Methods
contract=(contract)
click to toggle source
# File lib/hakuban/hakuban.rb, line 580 def contract=(contract) raise "You can't change contracts, sorry." if @contract @contract = contract case @contract.class.name when "Hakuban::ObjectObserve" then singleton_class.include(ObservedObjectManager) when "Hakuban::ObjectExpose" then singleton_class.include(ExposedObjectManager) when "Hakuban::TagObserve" then singleton_class.include(ObservedTagManager) when "Hakuban::TagExpose" then singleton_class.include(ExposedTagManager) else raise end @queue = Queue.new @contract.send_events_to(@queue, :object) if @contract.kind_of?(ObjectObserve) or @contract.kind_of?(ObjectExpose) event, param, descriptor = @queue.pop raise if event != :object or param != :insert or not descriptor self[descriptor] = self.construct_object(@contract, descriptor) end @thread = Thread.new { loop { event,param,descriptor = @queue.shift case [event, param] when [:control, :quit] break when [:object, :insert] self[descriptor] = construct_object(@contract, descriptor) object_insert(self[descriptor]) when [:object, :change] object_change(self[descriptor]) when [:object, :remove] object_remove(delete(descriptor)) end } } end
drop()
click to toggle source
# File lib/hakuban/hakuban.rb, line 631 def drop @contract.stop_sending_objects_events_to(@queue) @queue.push [:control, :quit] @thread.join @queue, @contract, @thread, @objects = nil, nil, nil, {} end
object_change(object)
click to toggle source
# File lib/hakuban/hakuban.rb, line 622 def object_change(object) # noop default end
object_insert(object)
click to toggle source
# File lib/hakuban/hakuban.rb, line 618 def object_insert(object) # noop default end
object_remove(object)
click to toggle source
# File lib/hakuban/hakuban.rb, line 626 def object_remove(object) # noop default end