PageRenderTime 112ms CodeModel.GetById 105ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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