Ruby中面向方面编程

gun*_*888 2 ruby aop frameworks aspects

将AOP添加到Ruby有哪些框架?

Aje*_*i32 9

使用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)

输出:

记录鲁弗斯的树皮!

鲁弗斯狗说树皮!


Mat*_*all 8

你没有指定任何评估不同框架的标准,所以这是我在Google上3秒钟后发现的一个:Aquarium.


再一个,通过建议@Telemachus:基色.

  • 是的,我做了同样的事情:谷歌建议你[水族馆](https://github.com/deanwampler/Aquarium)和[凝视](https://github.com/teejayvanslyke/gazer). (2认同)