Module: Jade::Interop::Runtime
- Included in:
- Runtime
- Defined in:
- lib/jade/interop/runtime.rb
Instance Method Summary collapse
-
#encode_args(args, encoders) ⇒ Object
Ports are the boundary in the other direction: what Ruby gets handed is encoded the same way a return value is decoded on the way back.
- #task_call(interop_module_name, function_name, ok_decoder, err_decoder, arg_encoders) ⇒ Object
Instance Method Details
#encode_args(args, encoders) ⇒ Object
Ports are the boundary in the other direction: what Ruby gets handed is encoded the same way a return value is decoded on the way back.
25 26 27 28 29 |
# File 'lib/jade/interop/runtime.rb', line 25 def encode_args(args, encoders) args .each_with_index .map { |arg, i| encoders.fetch(i).call(arg) } end |
#task_call(interop_module_name, function_name, ok_decoder, err_decoder, arg_encoders) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/jade/interop/runtime.rb', line 6 def task_call(interop_module_name, function_name, ok_decoder, err_decoder, arg_encoders) ->(*args) do interop_module_name .send(function_name) .then do |port| port.is_a?(Jade::TaskDef) || fail(Interop::PortNotRegistered.new(interop_module_name, function_name)) Jade::Task::Decoded.new( Jade::Task::Dispatch.new(port, encode_args(args, arg_encoders)), ok_decoder, err_decoder, ) end end end |