使用Ruby 2.0+,您不一定需要一个框架:
module BarkLogger
def bark
puts "Logging #@name's bark!"
super
end
end
class Dog
prepend BarkLogger
def initialize(name)
@name = name
end
def bark
puts "#@name the dog says bark!"
end
end
Dog.new("Rufus").bark
Run Code Online (Sandbox Code Playgroud)
输出:
记录鲁弗斯的树皮!
鲁弗斯狗说树皮!
你没有指定任何评估不同框架的标准,所以这是我在Google上3秒钟后发现的一个:Aquarium.
再一个,通过建议@Telemachus:基色.
| 归档时间: |
|
| 查看次数: |
4762 次 |
| 最近记录: |