Permalink
Browse files

Apply to selected methods only

  • Loading branch information...
1 parent 90d8152 commit a452c66c6781b37450a33447816dc69e7dcbf1d2 @gcao committed Mar 13, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 lib/aspector/base.rb
View
@@ -82,6 +82,21 @@ def aop_apply
def aop_apply_to_methods
advices = aop_advices
+
+ # If method/methods option is set and all are String or Symbol, apply to those only, instead of
+ # iterating through all methods
+ methods = [@aop_options[:method] || @aop_options[:methods]]
+ methods.compact!
+ methods.flatten!
+
+ if not methods.empty? and methods.all?{|method| method.is_a? String or method.is_a? Symbol }
+ methods.each do |method|
+ aop_apply_to_method(method.to_s, advices)
+ end
+
+ return
+ end
+
@aop_context.public_instance_methods.each do |method|
aop_apply_to_method(method.to_s, advices, :public)
end

0 comments on commit a452c66

Please sign in to comment.