diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-13 16:59:05 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-13 16:59:05 -0700 |
commit | 73aefee3f23f54786c69f1bafa5b1f0b5aee8398 (patch) | |
tree | 993574a152033c2abab003edbaa0d90b167f54f0 | |
parent | d2c0571bf6161e859ccc9c91a7d87b2bffa35dd5 (diff) | |
download | rails-73aefee3f23f54786c69f1bafa5b1f0b5aee8398.tar.gz rails-73aefee3f23f54786c69f1bafa5b1f0b5aee8398.tar.bz2 rails-73aefee3f23f54786c69f1bafa5b1f0b5aee8398.zip |
use a singleton end node
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index fa37b24f51..3be23c17e1 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -96,6 +96,15 @@ module ActiveSupport module Filters Environment = Struct.new(:target, :halted, :value, :run_block) + + class End + def call(env) + block = env.run_block + env.value = !env.halted && (!block || block.call) + env + end + end + ENDING = End.new end class Callback #:nodoc:# @@ -361,11 +370,7 @@ module ActiveSupport def compile return @callbacks if @callbacks - @callbacks = lambda { |env| - block = env.run_block - env.value = !env.halted && (!block || block.call) - env - } + @callbacks = Filters::ENDING @chain.reverse_each do |callback| @callbacks = callback.apply(@callbacks) end |