Class: Conquer::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/conquer/container.rb

Direct Known Subclasses

Scroller

Defined Under Namespace

Classes: Worker

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic) ⇒ Container

Returns a new instance of Container.



36
37
38
39
# File 'lib/conquer/container.rb', line 36

def initialize(topic)
  @topic = topic
  @children = {}
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



34
35
36
# File 'lib/conquer/container.rb', line 34

def children
  @children
end

Instance Method Details

#register(child_class, *args) ⇒ Object



41
42
43
44
# File 'lib/conquer/container.rb', line 41

def register(child_class, *args)
  id = SecureRandom.uuid
  @children[id] = child_class.new(id, *args)
end

#start_workerObject



46
47
48
49
# File 'lib/conquer/container.rb', line 46

def start_worker
  Worker.supervise(args: [@topic, @children.keys])
  @children.values.each(&:start_worker)
end