Module: Context Private
- Extended by:
- MonitorMixin
- Included in:
- AbstractDownloadStrategy, Cask::CaskLoader, Cask::Download, Cleaner, Downloadable, Downloadable::VerificationCache, Formula, FormulaVersions, Formulary, Formulary::FormulaLoader, GitHubPackages, GitHubReleases, Homebrew, Homebrew::Assertions, Migrator, ObserverPathnameExtension, SystemCommand, SystemCommand::Result, Utils::Analytics
- Defined in:
- context.rb
Overview
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.
Module for querying the current execution context.
Defined Under Namespace
Classes: ContextStruct
Class Method Summary collapse
- .current ⇒ ContextStruct private
- .current=(context) ⇒ void private
Instance Method Summary collapse
- #debug? ⇒ Boolean private
- #deferred_environment_expansion? ⇒ Boolean private
- #quiet? ⇒ Boolean private
- #verbose? ⇒ Boolean private
- #with_context(debug: debug?, , quiet: quiet?, , verbose: verbose?, , deferred_environment_expansion: deferred_environment_expansion?, , tolerate_formula_load_errors: Context.current.tolerate_formula_load_errors?, &_block) ⇒ T.untyped private
Class Method Details
.current ⇒ ContextStruct
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.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'context.rb', line 64 def self.current current_context = T.cast(Thread.current[:context], T.nilable(ContextStruct)) return current_context if current_context synchronize do current = T.let(@current, T.nilable(ContextStruct)) current ||= ContextStruct.new @current = current current end end |
.current=(context) ⇒ 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.
57 58 59 60 61 |
# File 'context.rb', line 57 def self.current=(context) synchronize do @current = context end end |
Instance Method Details
#debug? ⇒ Boolean
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.
77 78 79 |
# File 'context.rb', line 77 def debug? Context.current.debug? end |
#deferred_environment_expansion? ⇒ Boolean
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.
92 93 94 |
# File 'context.rb', line 92 def deferred_environment_expansion? Context.current.deferred_environment_expansion? end |
#quiet? ⇒ Boolean
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.
82 83 84 |
# File 'context.rb', line 82 def quiet? Context.current.quiet? end |
#verbose? ⇒ Boolean
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.
87 88 89 |
# File 'context.rb', line 87 def verbose? Context.current.verbose? end |
#with_context(debug: debug?, , quiet: quiet?, , verbose: verbose?, , deferred_environment_expansion: deferred_environment_expansion?, , tolerate_formula_load_errors: Context.current.tolerate_formula_load_errors?, &_block) ⇒ T.untyped
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.
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'context.rb', line 106 def with_context(debug: debug?, quiet: quiet?, verbose: verbose?, deferred_environment_expansion: deferred_environment_expansion?, tolerate_formula_load_errors: Context.current.tolerate_formula_load_errors?, &_block) old_context = Context.current Thread.current[:context] = ContextStruct.new(debug:, quiet:, verbose:, deferred_environment_expansion:, tolerate_formula_load_errors:) begin yield ensure Thread.current[:context] = old_context end end |