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 1559

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 1617

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

#init_with_client (private)

[ GitHub ]

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

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 1565

def perform
  @result = nil
  @succ = false
  setup_message

  if $SAFE < @safe_level
    info = Thread.current['DRb']
    if @block
      @result = Thread.new do
        Thread.current['DRb'] = info
        prev_safe_level = $SAFE
        $SAFE = @safe_level
        perform_with_block
      ensure
        $SAFE = prev_safe_level
      end.value
    else
      @result = Thread.new do
        Thread.current['DRb'] = info
        prev_safe_level = $SAFE
        $SAFE = @safe_level
        perform_without_block
      ensure
        $SAFE = prev_safe_level
      end.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 1626

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 1621

def setup_message
  init_with_client
  check_insecure_method
end