Class: Async::App
Defined Under Namespace
Modules: AutoloadComponent, Component, Injector, TimerComponent, WebComponent
Classes: EventLogger, WebServer
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Component
#after_init, #after_run, included, #start!
Class Method Details
.instance ⇒ Object
7
|
# File 'lib/async/app.rb', line 7
def instance = @instance = instances(self).first
|
.instances(klass) ⇒ Object
9
|
# File 'lib/async/app.rb', line 9
def instances(klass) = ObjectSpace.each_object(klass)
|
Instance Method Details
#autoloadable_components ⇒ Object
33
|
# File 'lib/async/app.rb', line 33
def autoloadable_components = components.select { _1.included_modules.include?(AutoloadComponent) }
|
#components ⇒ Object
32
|
# File 'lib/async/app.rb', line 32
def components = instances(Class).select { _1.included_modules.include?(Component) }.reject { _1 <= self.class }
|
#container ⇒ Object
30
|
# File 'lib/async/app.rb', line 30
def container = @container ||= Dry::Container.new
|
#init! ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/async/app.rb', line 12
def init!
raise "only one instance of #{self.class} is allowed" if instances(self.class).count > 1
@parent = Async::Task.current
set_traps!
init_container!
super
rescue StandardError => e
fatal { e }
stop!
exit(1)
end
|
#instances(klass) ⇒ Object
31
|
# File 'lib/async/app.rb', line 31
def instances(klass) = self.class.instances(klass)
|
#stop! ⇒ Object
25
26
27
28
|
# File 'lib/async/app.rb', line 25
def stop!
@parent&.stop(true)
super
end
|
#timer_components ⇒ Object
34
|
# File 'lib/async/app.rb', line 34
def timer_components = components.select { _1.included_modules.include?(TimerComponent) }
|