class Dizby::InvokeMethod
Public Class Methods
new(server, obj, msg, argv, block)
click to toggle source
# File lib/dizby/worker/invoke_method.rb, line 11 def initialize(server, obj, msg, argv, block) @obj = obj @msg_id = msg.to_sym @argv = argv @block = block && proc { |*args| call_block(block, *args) } @server = server end
Public Instance Methods
perform()
click to toggle source
# File lib/dizby/worker/invoke_method.rb, line 20 def perform result = send_to_object # TODO: do we care what the @msg_id is? # Should we convert to a DistributedArray regardless? if @msg_id == :to_ary && result.class == Array result = DistributedArray.new(result, @server) end [true, result] rescue StandardError, ScriptError, Interrupt @server.log.backtrace($!) [false, $!] end
Private Instance Methods
call_block(block, *args)
click to toggle source
# File lib/dizby/worker/invoke_method.rb, line 37 def call_block(block, *args) if args.size == 1 && args[0].is_a?(Array) args[0] = DistributedArray.new(args[0], @server) end block.call(*args) rescue LocalJumpError handle_jump_error($!) end
handle_jump_error(err)
click to toggle source
# File lib/dizby/worker/invoke_method.rb, line 47 def handle_jump_error(err) case err.reason when :break err.exit_value else raise err end end
send_to_object()
click to toggle source
# File lib/dizby/worker/invoke_method.rb, line 56 def send_to_object @obj.__send__(@msg_id, *@argv, &@block) end