Sha256: b5cc42d27757042b83ff39627a88a92272bc46aa30b7b793ce8c0864c7b3eab2

Contents?: true

Size: 1003 Bytes

Versions: 7

Compression:

Stored size: 1003 Bytes

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 Gloo
  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

        arr = Gloo::Core::ObjFinder.by_name 'on_load', obj
        arr.each { |o| Gloo::Exec::Dispatch.message 'run', o }
      end

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

        arr = Gloo::Core::ObjFinder.by_name 'on_unload', obj
        arr.each { |o| Gloo::Exec::Dispatch.message 'run', o }
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gloo-0.6.1 lib/gloo/core/event_manager.rb
gloo-0.6.0 lib/gloo/core/event_manager.rb
gloo-0.5.4 lib/gloo/core/event_manager.rb
gloo-0.5.3 lib/gloo/core/event_manager.rb
gloo-0.5.2 lib/gloo/core/event_manager.rb
gloo-0.5.1 lib/gloo/core/event_manager.rb
gloo-0.5.0 lib/gloo/core/event_manager.rb