我有一堆类似逻辑的类
class ApiWrapper
class << self
attr_accessor :app_id, :app_key
def configure
yield self
end
end
end
我想将此逻辑提取到类似于Ruby Struct类的模块,以便能够执行类似这样的操作
class ApiWrapper
include Configurable.instance :app_id, :app_key
end
我该怎么做?
答案 0 :(得分:1)
fred = Module.new do
def meth1
"hello"
end
def meth2
"bye"
end
end