3

What frameworks exist to add AOP to Ruby?

gunit888
  • 571
  • 6
  • 14

5 Answers5

13

With Ruby 2.0+, you don't necessarily need a framework:

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

Output:

Logging Rufus's bark!

Rufus the dog says bark!

Ajedi32
  • 45,670
  • 22
  • 127
  • 172
8

You haven't specified any criteria for evaluating different frameworks, so here's one that I found after 3 seconds on Google: Aquarium.


Another one, suggested by @Telemachus: gazer.

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
2

Shameless plug: aspector could be what you are looking for. It allows you to define aspect and then apply to one or more targets.

Guoliang Cao
  • 507
  • 4
  • 11
1

I tried 2 or 3 years ago Aquarium gem at university project. Worked nice, aim of project was comparing with AspectJ, to find out if it is capable of all things as AspectJ. At that time a lot of functionality, which AspectJ was capable of, was missing. But now I see a many things were added, so it's worth a try again.

guitarman
  • 641
  • 4
  • 5
0

AspectR (last release looks like in 2002) - originally the canonical AOP library in Ruby.

Facets - has some AOP functionality.

Duke
  • 7,070
  • 3
  • 38
  • 28