Sha256: d38de2d48aae803250efc6d8631a1125e3cc1d863cc3ef60e19e6b432e5e6b70
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
class RubyProcess #Spawns a new object in the process and returns a proxy-object for it. def new(classname, *args, &block) return send(cmd: :new, classname: classname, args: parse_args(args), &block) end #This command spawns a new object of a given class and returns its hash-handle, so a proxy-object can be spawned on the other side. def cmd_new(obj) const = obj[:classname].to_s.split("::").inject(Object, :const_get) debug "New-args-before: #{obj[:args]}\n" if @debug real_args = read_args(obj[:args]) debug "New-args-after: #{real_args}\n" if @debug retobj = const.new(*real_args) return handle_return_object(retobj) end #Calls a method on an object. def cmd_obj_method(obj) myobj = @objects[obj[:id]] raise "Object by that ID does not exist: '#{obj[:id]}' '(#{@objects.keys.sort.join(",")})." if !myobj if obj.key?(:block) real_block = proc{|*args| debug "Block called! #{args}\n" if @debug send(cmd: :block_call, block_id: obj[:block][:id], answer_id: obj[:send_id], args: handle_return_args(args)) } block = block_with_arity(arity: obj[:block][:arity], &real_block) debug "Spawned fake block with arity: #{block.arity}\n" if @debug else block = nil end debug "Obj-method-args-before: #{obj[:args]}\n" if @debug real_args = read_args(obj[:args]) debug "Obj-methods-args-after: #{real_args}\n" if @debug debug "Calling #{myobj.class.name}.#{obj[:method]}(*#{obj[:args]}, &#{block})\n" if @debug res = myobj.__send__(obj[:method], *real_args, &block) return handle_return_object(res) end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
ruby_process-0.0.13 | cmds/new.rb |
RubyProcess-0.0.12 | cmds/new.rb |