class RubyProcess::ProxyObject

This class handels the calling of methods on objects in the other process seamlessly.

Constants

PROXY_METHODS

Overwrite certain methods.

RUBY_METHODS

Overwrite certain convert methods.

Attributes

__rp_id[R]

Hash that contains various information about the proxyobj.

__rp_pid[R]

Hash that contains various information about the proxyobj.

__rp_rp[R]

Hash that contains various information about the proxyobj.

Public Class Methods

new(rp, id, pid) click to toggle source

Constructor. This should not be called manually but through a running 'RubyProcess'.

Examples

proxy_obj = rp.new(:String, "Kasper") #=> <RubyProcess::ProxyObject>
proxy_obj = rp.static(:File, :open, "/tmp/somefile") #=> <RubyProcess::ProxyObject>
# File lib/ruby_process/proxy_object.rb, line 10
def initialize(rp, id, pid)
  @__rp_rp, @__rp_id, @__rp_pid = rp, id, pid
end

Public Instance Methods

__rp_destroy() click to toggle source

Unsets all data on the object.

# File lib/ruby_process/proxy_object.rb, line 23
def __rp_destroy
  @__rp_id = nil, @__rp_rp = nil, @__rp_pid = nil
end
__rp_marshal() click to toggle source

Returns the object as the real object transfered by using the marshal-lib.

Examples

str = rp.new(:String, "Kasper") #=> <RubyProcess::ProxyObject>
str.__rp_marshal #=> "Kasper"
# File lib/ruby_process/proxy_object.rb, line 18
def __rp_marshal
  return Marshal.load(@__rp_rp.send(cmd: :obj_marshal, id: @__rp_id))
end
method_missing(method, *args, &block) click to toggle source

Proxies all calls to the process-object.

Examples

str = rp.new(:String, "Kasper") #=> <RubyProcess::ProxyObject::1>
length_int = str.length #=> <RubyProcess::ProxyObject::2>
length_int.__rp_marshal #=> 6
# File lib/ruby_process/proxy_object.rb, line 48
def method_missing(method, *args, &block)
  debug "Method-missing-args-before: #{args} (#{@__rp_pid})\n" if @debug
  real_args = @__rp_rp.parse_args(args)
  debug "Method-missing-args-after: #{real_args}\n" if @debug

  return @__rp_rp.send(cmd: :obj_method, id: @__rp_id, method: method, args: real_args, &block)
end