Sha256: 637e97fd5e297401b83c1ab1b1b36cfc5cdfaad50d3ca53fe08865977c5c7f31

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2020 Eric Crane.  All rights reserved.
#
# Central Message Dispatch.
# Responsible for sending message to objects.
# All object messaging goes through here so we can uniformly
# manage things like checking to make sure object can
# receive the messages sent, handling errors, etc.
#

module Gloo
  module Exec
    class Dispatch

      #
      # Dispatch the given message to the given object.
      #
      def self.message( msg, to_obj, params = nil )
        $log.debug "Dispatch message #{msg} to #{to_obj.name}"
        a = Gloo::Exec::Action.new msg, to_obj, params
        Gloo::Exec::Dispatch.action a
      end

      #
      # Dispatch an action.
      #
      def self.action( action )
        unless action.valid?
          $log.warn "Object #{action.to.name} does not respond to #{action.msg}"
        end

        $engine.exec_env.push_action action
        $log.debug "Sending message #{action.msg} to #{action.to.name}"
        action.dispatch
        $engine.exec_env.pop_action
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gloo-0.8.0 lib/gloo/exec/dispatch.rb
gloo-0.7.7 lib/gloo/exec/dispatch.rb
gloo-0.7.6 lib/gloo/exec/dispatch.rb
gloo-0.7.5 lib/gloo/exec/dispatch.rb
gloo-0.7.4 lib/gloo/exec/dispatch.rb
gloo-0.7.3 lib/gloo/exec/dispatch.rb
gloo-0.7.2 lib/gloo/exec/dispatch.rb
gloo-0.7.1 lib/gloo/exec/dispatch.rb
gloo-0.7.0 lib/gloo/exec/dispatch.rb
gloo-0.6.1 lib/gloo/exec/dispatch.rb
gloo-0.6.0 lib/gloo/exec/dispatch.rb