Module: Context Private
- Extended by:
- MonitorMixin
- Included in:
- AbstractDownloadStrategy, Cask::CaskLoader, Cask::Download, Cleaner, Downloadable, 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?, , &_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.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'context.rb', line 58 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.
51 52 53 54 55 |
# File 'context.rb', line 51 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.
71 72 73 |
# File 'context.rb', line 71 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.
86 87 88 |
# File 'context.rb', line 86 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.
76 77 78 |
# File 'context.rb', line 76 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.
81 82 83 |
# File 'context.rb', line 81 def verbose? Context.current.verbose? end |
#with_context(debug: debug?, , quiet: quiet?, , verbose: verbose?, , deferred_environment_expansion: deferred_environment_expansion?, , &_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.
99 100 101 102 103 104 105 106 107 108 109 |
# File 'context.rb', line 99 def with_context(debug: debug?, quiet: quiet?, verbose: verbose?, deferred_environment_expansion: deferred_environment_expansion?, &_block) old_context = Context.current Thread.current[:context] = ContextStruct.new(debug:, quiet:, verbose:, deferred_environment_expansion:) begin yield ensure Thread.current[:context] = old_context end end |