Spec-Zone.ru › Homebrew

Module: Ignorable Private

Includes:
Kernel
Defined in:
ignorable.rb,
ignorable.rbi

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Defined Under Namespace

Modules: ExceptionMixin

Constant Summary

Constants included from Kernel

Kernel::IGNORE_INTERRUPTS_MUTEX

Class Method Summary collapse

  • .hook_raise(&blk) ⇒ void private
  • .raise ⇒ Object private

    This is a workaround to enable raise to be aliased.

  • .unhook_raise ⇒ void private

Methods included from Kernel

#ensure_executable!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #quiet_system, #redirect_stdout, #safe_system, #which, #which_editor, #with_env, #with_homebrew_path

Class Method Details

.hook_raise(&blk) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:

  • blk (T.proc.void, nil)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'ignorable.rb', line 24

def self.hook_raise(&blk)
  Object.class_eval do
    alias_method :original_raise, :raise

    # `define_method` keeps Sorbet happy inside this `class_eval` block.
    define_method(:raise) do |*args|
      callcc do |continuation|
        super(*args)
      # Handle all possible exceptions.
      rescue Exception => e # rubocop:disable Lint/RescueException
        unless e.is_a?(ScriptError)
          e.extend(ExceptionMixin)
          T.cast(e, ExceptionMixin).continuation = continuation
        end
        super(e)
      end
    end

    alias_method :fail, :raise
  end

  return unless block_given?

  yield
  unhook_raise
end

.raise ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This is a workaround to enable raise to be aliased

See Also:

  • https://github.com/sorbet/sorbet/issues/2378#issuecomment-569474238


8
# File 'ignorable.rbi', line 8

def self.raise(*); end

.unhook_raise ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



52
53
54
55
56
57
58
# File 'ignorable.rb', line 52

def self.unhook_raise
  Object.class_eval do
    alias_method :raise, :original_raise
    alias_method :fail, :original_raise
    undef_method :original_raise
  end
end

© 2009–present Homebrew contributors
Licensed under the BSD 2-Clause License.
https://docs.brew.sh/rubydoc/Ignorable.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API