Project1

标题: 关于Ruby的Proxy。。。 [打印本页]

作者: LBQ    时间: 2013-6-29 14:13
标题: 关于Ruby的Proxy。。。
我实在是不知道去哪里问这个问题了=。=,所以还是来这里求助了,于是先上脚本=-=
RUBY 代码复制
  1. #==============================================================================
  2. # Dynamic Proxy
  3. #==============================================================================
  4. module DynamicProxy_Mixin
  5.   def self.included(base)
  6.     base.extend(Proxy_Methods)
  7.   end
  8.  
  9.   module Proxy_Methods
  10.     def add_new_proxy(*args)
  11.       class_eval %{
  12.         def proxy_methods_targets
  13.           #{args}
  14.         end
  15.  
  16.         def method_missing(name,*args,&block)
  17.           proxy_methods_targets.each{|target| target.send(name,*args,&block)}
  18.         end
  19.  
  20.       }
  21.  
  22.     end
  23.   end
  24. end


于是这个脚本的用处就是。。
RUBY 代码复制
  1. class ProxyTest
  2.   include DynamicProxy_Mixin
  3.  
  4.   add_new_proxy @sprite
  5.   def initialize
  6.     @sprite=Sprite.new
  7.   end
  8.  
  9.  
  10.  
  11. end
  12.  
  13. proxy=ProxyTest.new
  14. proxy.visible=false #其实是将sprite的visible设置为false


于是乎现在不知道该怎么办于是就来求助了=-=。求解答
作者: asperta    时间: 2013-6-29 19:35
这脚本是哪找的?求助些什么?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1