diff options
author | José Valim <jose.valim@gmail.com> | 2012-05-17 02:28:19 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-05-17 02:28:19 -0700 |
commit | 17f583b7bc004adbb1ac44f156c806df018c7365 (patch) | |
tree | 7ef44cedaea9d26174cb3b9dea0533b938ca5d50 /activesupport | |
parent | 6950d74e18750434dbf76fd6749a7c8f393f53be (diff) | |
parent | 8a72e7e6fda77eb76043bffd048208f7199ddfa0 (diff) | |
download | rails-17f583b7bc004adbb1ac44f156c806df018c7365.tar.gz rails-17f583b7bc004adbb1ac44f156c806df018c7365.tar.bz2 rails-17f583b7bc004adbb1ac44f156c806df018c7365.zip |
Merge pull request #6362 from bogdan/callbacks_simplify_statement
AS::Callbacks: simplify logical statement
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 4 |
1 files changed, 2 insertions, 2 deletions
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 |