From 8a72e7e6fda77eb76043bffd048208f7199ddfa0 Mon Sep 17 00:00:00 2001 From: Bogdan Gusiev Date: Thu, 17 May 2012 11:24:39 +0300 Subject: AS::Callbacks: simplify logical statement --- activesupport/lib/active_support/callbacks.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 4e319b4bba..0aa3efbb63 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -310,13 +310,13 @@ module ActiveSupport method << "value = nil" method << "halted = false" - callbacks = "value = yield if block_given? && !halted" + callbacks = "value = !halted && (!block_given? || yield)" reverse_each do |callback| callbacks = callback.apply(callbacks) end method << callbacks - method << "halted ? false : (block_given? ? value : true)" + method << "value" method.join("\n") end -- cgit v1.2.3