Skip to content

Commit

Permalink
AS::Callbacks: simplify logical statement
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed May 17, 2012
1 parent 4edb497 commit 8a72e7e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions activesupport/lib/active_support/callbacks.rb
Expand Up @@ -310,13 +310,13 @@ def compile
method << "value = nil" method << "value = nil"
method << "halted = false" method << "halted = false"


callbacks = "value = yield if block_given? && !halted" callbacks = "value = !halted && (!block_given? || yield)"
reverse_each do |callback| reverse_each do |callback|
callbacks = callback.apply(callbacks) callbacks = callback.apply(callbacks)
end end
method << callbacks method << callbacks


method << "halted ? false : (block_given? ? value : true)" method << "value"
method.join("\n") method.join("\n")
end end


Expand Down

0 comments on commit 8a72e7e

Please sign in to comment.