/tools/Ruby/lib/ruby/1.8/drb/invokemethod.rb

http://github.com/agross/netopenspace · Ruby · 36 lines · 33 code · 2 blank · 1 comment · 5 complexity · 73deb16b862b9abf7ebf2692b39b51f0 MD5 · raw file

  1. # for ruby-1.8.0
  2. module DRb
  3. class DRbServer
  4. module InvokeMethod18Mixin
  5. def block_yield(x)
  6. if x.size == 1 && x[0].class == Array
  7. x[0] = DRbArray.new(x[0])
  8. end
  9. block_value = @block.call(*x)
  10. end
  11. def perform_with_block
  12. @obj.__send__(@msg_id, *@argv) do |*x|
  13. jump_error = nil
  14. begin
  15. block_value = block_yield(x)
  16. rescue LocalJumpError
  17. jump_error = $!
  18. end
  19. if jump_error
  20. case jump_error.reason
  21. when :retry
  22. retry
  23. when :break
  24. break(jump_error.exit_value)
  25. else
  26. raise jump_error
  27. end
  28. end
  29. block_value
  30. end
  31. end
  32. end
  33. end
  34. end