Class: GlooLang::Core::EventManager

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo_lang/core/event_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(engine) ⇒ EventManager

Set up the event manager.



15
16
17
18
# File 'lib/gloo_lang/core/event_manager.rb', line 15

def initialize( engine )
  @engine = engine
  @engine.log.debug 'event manager intialized...'
end

Instance Method Details

#on_load(obj = nil, in_heap = false) ⇒ Object

Run on_load scripts in the recently loaded object If no obj is given the script will be run in root.



24
25
26
27
28
29
30
# File 'lib/gloo_lang/core/event_manager.rb', line 24

def on_load( obj = nil, in_heap = false )
  return unless obj || in_heap

  @engine.log.debug 'on_load event'
  arr = GlooLang::Core::ObjFinder.by_name( @engine, 'on_load', obj )
  arr.each { |o| GlooLang::Exec::Dispatch.message( @engine, 'run', o ) }
end

#on_unload(obj) ⇒ Object

Run on_unload scripts in the object that will be unloaded.



35
36
37
38
39
40
41
# File 'lib/gloo_lang/core/event_manager.rb', line 35

def on_unload( obj )
  return unless obj

  @engine.log.debug 'on_unload event'
  arr = GlooLang::Core::ObjFinder.by_name( @engine, 'on_unload', obj )
  arr.each { |o| GlooLang::Exec::Dispatch.message( @engine, 'run', o ) }
end