Permalink
Browse files

if there is nothing to compile, then do not bother compiling

  • Loading branch information...
tenderlove committed May 13, 2013
1 parent 877964d commit ccbefff684d63c71e13fbb7507fa41d3400c0c95
Showing with 8 additions and 3 deletions.
  1. +8 −3 activesupport/lib/active_support/callbacks.rb
@@ -76,9 +76,14 @@ module Callbacks
# save
# end
def run_callbacks(kind, &block)
- runner = send("_#{kind}_callbacks").compile
- e = Filters::Environment.new(self, false, nil, block)
- runner.call(e).value
+ cbs = send("_#{kind}_callbacks")
+ if cbs.empty?
+ yield if block_given?
+ else
+ runner = cbs.compile
+ e = Filters::Environment.new(self, false, nil, block)
+ runner.call(e).value
+ end
end
private

0 comments on commit ccbefff

Please sign in to comment.