共享作用域 2015/08/15 15909 def define_methods shared = 0 Kernel.send :define_method, :counter do p shared end Kernel.send :define_method, :inc do |x| shared += x end end define_methods counter # => 0 inc(4) counter # => 4