Sha256: e65896ff61c6f55ba46ebdb975dfbd3a0cc71a33789f840f494649bbc605b4bb

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

module Byebug
  module Helpers
    #
    # Utilities used by the eval command
    #
    module EvalHelper
      #
      # 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.
      #
      def allowing_other_threads
        Byebug.unlock
        res = yield
        Byebug.lock
        res
      end

      #
      # Get current binding and yield it to the given block
      #
      def run_with_binding
        binding = get_binding
        yield binding
      end

      #
      # Evaluate +expression+ using +binding+
      #
      # @param binding [Binding] Context where to evaluate the expression
      # @param expression [String] Expression to evaluation
      # @param stack_on_error [Boolean] Whether to show a stack trace on error.
      #
      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
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/byebug-5.0.0/lib/byebug/helpers/eval.rb
byebug-5.0.0 lib/byebug/helpers/eval.rb