module ATU

Public Class Methods

<<(path) click to toggle source

load path

# File lib/woolen_common/ruby_proxy/client.rb, line 68
def <<(path)
    RubyProxy::DRbClient.add_load_path(path)
end
[](arg) click to toggle source
# File lib/woolen_common/ruby_proxy/client.rb, line 59
def [](arg)
    RubyProxy::DRbClient.proxy_global_get(arg)
end
[]=(arg, var) click to toggle source
# File lib/woolen_common/ruby_proxy/client.rb, line 63
def []=(arg, var)
    RubyProxy::DRbClient.proxy_global_set(arg, var)
end
const_missing(name) click to toggle source

entry

# File lib/woolen_common/ruby_proxy/client.rb, line 74
def self.const_missing(name)
    name = self.name.to_s + '::' + name.to_s
    type = RubyProxy::DRbClient.client.proxy_type(name)
    make_kclass(name, type)
end
make_kclass(name, type) click to toggle source
# File lib/woolen_common/ruby_proxy/client.rb, line 80
def self.make_kclass(name, type)
    #puts "make_kclass: #{name}, #{type}"
    case type
        when 'Class'
            RubyProxy::KlassFactory.make_class(name) do |klass|
                klass.class_eval do
                    def initialize(*arg)
                        @proxy = RubyProxy::DRbClient.client.proxy(self.class.to_s, "new", *arg)
                    end

                    # I think all methods should be proxyed by remote
                    undef :type rescue nil
                    undef :to_s
                    undef :to_a if respond_to?(:to_a)
                    undef :methods

                    def __proxy
                        @proxy
                    end

                    def method_missing(name, *arg, &block)
                        #return if @proxy.nil?
                        #puts "#{@proxy.methods(false)}"
                        #puts "proxy = #{@proxy} method=#{name} arg=#{arg.join(',')}"
                        @proxy.__send__(name, *arg, &block)
                    end

                    def self.const_missing(name)
                        name = self.name.to_s + "::" + name.to_s
                        type = RubyProxy::DRbClient.client.proxy_type(name.to_s)
                        ret = ATU::make_kclass(name, type)
                        case type
                            when 'Module', 'Class'
                                return ret
                        end
                        RubyProxy::DRbClient.client.proxy(name.to_s)
                    end

                    # TODO: block not support now
                    def self.method_missing(name, *arg, &block)
                        # puts "need to do method_missing :#{name}"
                        RubyProxy::DRbClient.client.copy_env(ENV.to_hash)
                        ClientRet.job_id = RubyProxy::DRbClient.client.proxy(self.name.to_s, name.to_s, *arg, &block)
                        ClientRet.get_job_ret
                    end

                end
            end
        when 'Module'
            RubyProxy::KlassFactory.make_module(name) do |mod|
                mod.class_eval do
                    def self.method_missing(name, *arg)
                        RubyProxy::DRbClient.client.proxy(self.name.to_s, name.to_s, *arg)
                    end

                    def self.const_missing(name)
                        name = self.name.to_s + "::" + name.to_s
                        #puts "in module const_missing : #{name}"
                        type = RubyProxy::DRbClient.client.proxy_type(name.to_s)
                        ret = ATU::make_kclass(name, type)
                        case type
                            when 'Module', 'Class'
                                return ret
                        end
                        RubyProxy::DRbClient.client.proxy(name.to_s)
                    end
                end
            end
        else

    end

end
method_missing(name, *arg, &block) click to toggle source

TODO: block not support now

# File lib/woolen_common/ruby_proxy/client.rb, line 119
def self.method_missing(name, *arg, &block)
    # puts "need to do method_missing :#{name}"
    RubyProxy::DRbClient.client.copy_env(ENV.to_hash)
    ClientRet.job_id = RubyProxy::DRbClient.client.proxy(self.name.to_s, name.to_s, *arg, &block)
    ClientRet.get_job_ret
end
new(*arg) click to toggle source
# File lib/woolen_common/ruby_proxy/client.rb, line 86
def initialize(*arg)
    @proxy = RubyProxy::DRbClient.client.proxy(self.class.to_s, "new", *arg)
end
require(arg) click to toggle source
# File lib/woolen_common/ruby_proxy/client.rb, line 52
def require(arg)
    #TODO: path maybe confict
    #~ path= File.expand_path File.join(Dir.pwd,arg)
    #~ path += '.rb'
    RubyProxy::DRbClient.proxy_load(arg)
end
Also aliased as: require_old
require_old(arg)
Alias for: require

Public Instance Methods

__proxy() click to toggle source
# File lib/woolen_common/ruby_proxy/client.rb, line 96
def __proxy
    @proxy
end
method_missing(name, *arg, &block) click to toggle source
# File lib/woolen_common/ruby_proxy/client.rb, line 100
def method_missing(name, *arg, &block)
    #return if @proxy.nil?
    #puts "#{@proxy.methods(false)}"
    #puts "proxy = #{@proxy} method=#{name} arg=#{arg.join(',')}"
    @proxy.__send__(name, *arg, &block)
end