2012-03-01 26 views
1

我有這樣從方法返回動態生成的模塊

class ApiWrapper 
    class << self 
    attr_accessor :app_id, :app_key 

    def configure 
     yield self 
    end 
    end 
end 

我想提取這個邏輯類似於Ruby的結構類模塊,能夠做這樣的事一堆,有着相近邏輯類

class ApiWrapper 
    include Configurable.instance :app_id, :app_key 
end 

我該怎麼做?

回答