Created
June 7, 2010 21:39
-
-
Save gcao/429233 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
include Aspect4r | |
def test value | |
puts 'test' | |
value | |
end | |
around :test do |proxy, value| | |
puts 'around 1' | |
result = a4r_invoke proxy, value | |
puts 'around 2' | |
result | |
end | |
before_filter :test do |value| | |
puts 'before_filter' | |
value >= 0 | |
end | |
before :test do |value| | |
puts 'before' | |
end | |
after :test do |result, value| | |
puts 'after' | |
result | |
end | |
end | |
puts A.new.test(1) | |
# ==== Output ==== | |
# before_filter | |
# before | |
# around 1 | |
# test | |
# around 2 | |
# after | |
# 1 | |
puts A.new.test(-1) | |
# ==== Output ==== | |
# before_filter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class A
include Aspect4r
before :test, :validate
after :test, :handle_result
def test value
value
end
def validate value
end
def handle_result result, value
end
end