README.rdoc

aspect4r

Feature

extract common logic from multiple methods into before, after, around
advices

before_filter as method filters (work like before_filters in web
application)

advices can be customized (e.g. to take an optional method name argument)

work as a supporting piece for more complex AOP tasks

Usage

class A
include Aspect4r
around :test do |proxy_method, value|
a4r_invoke proxy_method, value
end
before :test do |value|
puts "entering test(#{value})"
end
before :test, :do_something
before_filter :test do |value|
value >= 0
end
after :test do |result, value|
puts "test(#{value}) returned #{result}"
result
end
after :test, :do_something_else
def test value
...
end
def do_something value
...
end
def do_something_else result, value
...
end
end