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:
parent
d2c0571bf6
commit
73aefee3f2
1 changed files with 10 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue