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
|
module Filters
|
||||||
Environment = Struct.new(:target, :halted, :value, :run_block)
|
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
|
end
|
||||||
|
|
||||||
class Callback #:nodoc:#
|
class Callback #:nodoc:#
|
||||||
|
@ -361,11 +370,7 @@ module ActiveSupport
|
||||||
def compile
|
def compile
|
||||||
return @callbacks if @callbacks
|
return @callbacks if @callbacks
|
||||||
|
|
||||||
@callbacks = lambda { |env|
|
@callbacks = Filters::ENDING
|
||||||
block = env.run_block
|
|
||||||
env.value = !env.halted && (!block || block.call)
|
|
||||||
env
|
|
||||||
}
|
|
||||||
@chain.reverse_each do |callback|
|
@chain.reverse_each do |callback|
|
||||||
@callbacks = callback.apply(@callbacks)
|
@callbacks = callback.apply(@callbacks)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue