Skip to content

Commit

Permalink
Minor performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
gcao committed Mar 12, 2012
1 parent 591bd56 commit 31cc0e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 4 additions & 1 deletion lib/aspector/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def initialize target, options = {}
after_initialize
end

def aop_disabled?
end

def aop_advices
shared_advices = self.class.aop_advices

Expand Down Expand Up @@ -243,7 +246,7 @@ def aop_recreate_method_with_advices method, before_advices, after_advices, arou
<% end %>
define_method :<%= method %> do |*args, &block|
return orig_method.bind(self).call(*args, &block) if aspect.class.aop_disabled?
return orig_method.bind(self).call(*args, &block) if aspect.aop_disabled?
<% if is_outermost %>
catch(:aop_return) do
Expand Down
12 changes: 5 additions & 7 deletions lib/aspector/base_class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ module ClassMethods
::Aspector::Base.extend(self)

def aop_enable
@aop_disabled = nil
def aop_disabled?
end
end
alias :enable :aop_enable

def aop_disable
@aop_disabled = true
def aop_disabled?
true
end
end
alias :disable :aop_disable

def aop_disabled?
@aop_disabled
end
alias :disabled? :aop_disabled?

def aop_advices
@aop_advices ||= []
end
Expand Down

0 comments on commit 31cc0e9

Please sign in to comment.