1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

use a singleton end node

This commit is contained in:
Aaron Patterson 2013-05-13 16:59:05 -07:00
parent d2c0571bf6
commit 73aefee3f2

View file

@ -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