more eagerly bail when the state is prevented

This commit is contained in:
http://jneen.net/ 2017-08-07 12:48:22 -07:00
parent 8a167554a9
commit 15bb6e1ed7

View file

@ -76,6 +76,8 @@ module DeclarativePolicy
@state = State.new
steps_by_score do |step, score|
return if !debug && @state.prevented?
passed = nil
case step.action
when :enable then
@ -93,10 +95,7 @@ module DeclarativePolicy
# been prevented.
unless @state.prevented?
passed = step.pass?
if passed
@state.prevent!
return unless debug
end
@state.prevent! if passed
end
debug << inspect_step(step, score, passed) if debug