Sha256: 405256aa189f3556c2f2513ae51dff75bc15acdf6bc178e5bccefd894dad8a03

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# The Event Manager.
# Run scripts in response to pre-defined events.
#

module GlooLang
  module Core
    class EventManager

      #
      # Set up the event manager.
      #
      def initialize
        $log.debug 'event manager intialized...'
      end

      #
      # Run on_load scripts in the recently loaded object
      # If no obj is given the script will be run in root.
      #
      def on_load( obj = nil, in_heap = false )
        return unless obj || in_heap

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

      #
      # Run on_unload scripts in the object that will be unloaded.
      #
      def on_unload( obj )
        return unless obj

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

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gloo-lang-0.9.8 lib/gloo_lang/core/event_manager.rb
gloo-lang-0.9.7 lib/gloo_lang/core/event_manager.rb
gloo-lang-0.9.6 lib/gloo_lang/core/event_manager.rb
gloo-lang-0.9.5 lib/gloo_lang/core/event_manager.rb
gloo-lang-0.9.4 lib/gloo_lang/core/event_manager.rb
gloo-lang-0.9.3 lib/gloo_lang/core/event_manager.rb