这个功能要模拟Groovy中Expando和Javascript中的{},这里要用到ruby自带的osstruct库
#!C:/Ruby192/bin/ruby.exe require 'ostruct' def mytest puts "a method" end o = OpenStruct.new o.method1 = mytest o.prop1 = "a property" puts o.method1 puts o.prop1