Class: Gloo::Exec::Dispatch
- Inherits:
-
Object
- Object
- Gloo::Exec::Dispatch
- Defined in:
- lib/gloo/exec/dispatch.rb
Constant Summary collapse
- OBJ_NOT_FOUND_ERR =
'Object was not found: '.freeze
Class Method Summary collapse
-
.action(engine, action) ⇒ Object
Dispatch an action.
-
.message(engine, msg, to_obj, params = nil) ⇒ Object
Dispatch the given message to the given object.
-
.send_message(engine, msg, to_obj_pn, params = nil) ⇒ Object
Send a message to an object of a given name (and path).
Class Method Details
.action(engine, action) ⇒ Object
Dispatch an action.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gloo/exec/dispatch.rb', line 46 def self.action( engine, action ) unless action.valid? engine.log.warn "Object #{action.to.name} does not respond to #{action.msg}" end engine.exec_env.push_action action engine.log.debug "Sending message #{action.msg} to #{action.to.name}" action.dispatch engine.exec_env.pop_action end |
.message(engine, msg, to_obj, params = nil) ⇒ Object
Dispatch the given message to the given object.
35 36 37 38 39 40 41 |
# File 'lib/gloo/exec/dispatch.rb', line 35 def self.( engine, msg, to_obj, params = nil ) return unless to_obj engine.log.debug "Dispatch message #{msg} to #{to_obj.name}" a = Gloo::Exec::Action.new msg, to_obj, params Gloo::Exec::Dispatch.action( engine, a ) end |
.send_message(engine, msg, to_obj_pn, params = nil) ⇒ Object
Send a message to an object of a given name (and path). Once the object is found, the message is dispatched.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gloo/exec/dispatch.rb', line 21 def self.( engine, msg, to_obj_pn, params = nil ) pn = Gloo::Core::Pn.new( engine, to_obj_pn ) target_obj = pn.resolve unless target_obj engine.err "#{OBJ_NOT_FOUND_ERR} #{to_obj_pn}" return end Gloo::Exec::Dispatch.( engine, msg, target_obj, params ) end |