Method: Cond.check_context
- Defined in:
- lib/cond/cond.rb
.check_context(keyword) ⇒ Object
:nodoc:
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/cond/cond.rb', line 93 def check_context(keyword) #:nodoc: section = Cond.code_section_stack.last case keyword when :restart unless section.is_a? RestartableSection Cond.original_raise( ContextError, "`#{keyword}' called outside of `restartable' block" ) end when :handle unless section.is_a? HandlingSection Cond.original_raise( ContextError, "`#{keyword}' called outside of `handling' block" ) end when :leave, :again unless section Cond.original_raise( ContextError, "`#{keyword}' called outside of `handling' or `restartable' block" ) end end end |