Commit 15bb6e1e authored by http://jneen.net/'s avatar http://jneen.net/

more eagerly bail when the state is prevented

parent 8a167554
...@@ -76,6 +76,8 @@ module DeclarativePolicy ...@@ -76,6 +76,8 @@ module DeclarativePolicy
@state = State.new @state = State.new
steps_by_score do |step, score| steps_by_score do |step, score|
return if !debug && @state.prevented?
passed = nil passed = nil
case step.action case step.action
when :enable then when :enable then
...@@ -93,10 +95,7 @@ module DeclarativePolicy ...@@ -93,10 +95,7 @@ module DeclarativePolicy
# been prevented. # been prevented.
unless @state.prevented? unless @state.prevented?
passed = step.pass? passed = step.pass?
if passed @state.prevent! if passed
@state.prevent!
return unless debug
end
end end
debug << inspect_step(step, score, passed) if debug debug << inspect_step(step, score, passed) if debug
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment