123456789_123456789_123456789_123456789_123456789_

Class: DRb::DRbServer::InvokeMethod

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/drb/drb.rb,
lib/drb/drb.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(drb_server, client) ⇒ InvokeMethod

[ GitHub ]

  
# File 'lib/drb/drb.rb', line 1560

def initialize(drb_server, client)
  @drb_server = drb_server
  @safe_level = drb_server.safe_level
  @client = client
end

Instance Method Details

#check_insecure_method (private)

[ GitHub ]

  
# File 'lib/drb/drb.rb', line 1612

def check_insecure_method
  @drb_server.check_insecure_method(@obj, @msg_id)
end

#init_with_client (private)

[ GitHub ]

  
# File 'lib/drb/drb.rb', line 1604

def init_with_client
  obj, msg, argv, block = @client.recv_request
  @obj = obj
  @msg_id = msg.intern
  @argv = argv
  @block = block
end

#perform

[ GitHub ]

  
# File 'lib/drb/drb.rb', line 1566

def perform
  @result = nil
  @succ = false
  setup_message

  if $SAFE < @safe_level
    info = Thread.current['DRb']
    if @block
      @result = Thread.new {
        Thread.current['DRb'] = info
        $SAFE = @safe_level
        perform_with_block
      }.value
    else
      @result = Thread.new {
        Thread.current['DRb'] = info
        $SAFE = @safe_level
        perform_without_block
      }.value
    end
  else
    if @block
      @result = perform_with_block
    else
      @result = perform_without_block
    end
  end
  @succ = true
  if @msg_id == :to_ary && @result.class == Array
    @result = DRbArray.new(@result)
  end
  return @succ, @result
rescue StandardError, ScriptError, Interrupt
  @result = $!
  return @succ, @result
end

#perform_without_block (private)

[ GitHub ]

  
# File 'lib/drb/drb.rb', line 1621

def perform_without_block
  if Proc === @obj && @msg_id == :__drb_yield
    if @argv.size == 1
      ary = @argv
    else
      ary = [@argv]
    end
    ary.collect(&@obj)[0]
  else
    @obj.__send__(@msg_id, *@argv)
  end
end

#setup_message (private)

[ GitHub ]

  
# File 'lib/drb/drb.rb', line 1616

def setup_message
  init_with_client
  check_insecure_method
end