Module: Byebug::EvalFunctions
- Included in:
- EvalCommand, PPCommand, PSCommand, PutLCommand
- Defined in:
- lib/byebug/commands/eval.rb
Overview
Utilities used by the eval command
Instance Method Summary collapse
-
#allowing_other_threads ⇒ Object
Run block temporarily ignoring all TracePoint events.
-
#eval_with_setting(binding, expression, stack_on_error) ⇒ Object
Evaluate
expression
usingbinding
. -
#run_with_binding {|binding| ... } ⇒ Object
Get current binding and yield it to the given block.
Instance Method Details
#allowing_other_threads ⇒ Object
Run block temporarily ignoring all TracePoint events.
Used to evaluate stuff within Byebug’s prompt. Otherwise, any code creating new threads won’t be properly evaluated because new threads will get blocked by byebug’s main thread.
18 19 20 21 22 23 |
# File 'lib/byebug/commands/eval.rb', line 18 def allowing_other_threads Byebug.unlock res = yield Byebug.lock res end |
#eval_with_setting(binding, expression, stack_on_error) ⇒ Object
Evaluate expression
using binding
40 41 42 43 44 45 46 47 48 |
# File 'lib/byebug/commands/eval.rb', line 40 def eval_with_setting(binding, expression, stack_on_error) allowing_other_threads do if stack_on_error bb_eval(expression, binding) else bb_warning_eval(expression, binding) end end end |
#run_with_binding {|binding| ... } ⇒ Object
Get current binding and yield it to the given block
28 29 30 31 |
# File 'lib/byebug/commands/eval.rb', line 28 def run_with_binding binding = get_binding yield binding end |