Module: Homebrew::Tapioca::Utils Private
- Defined in:
- sorbet/tapioca/utils.rb
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.
Class Method Summary collapse
-
.methods_from_file(mod, file_name, class_methods: false) ⇒ Array<Method, UnboundMethod>
private
The
module
methods that are defined in the given file. - .named_object_for(klass) ⇒ Module private
- .named_objects_with_module(mod) ⇒ Array<Module> private
Class Method Details
.methods_from_file(mod, file_name, class_methods: false) ⇒ Array<Method, UnboundMethod>
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.
Returns the module
methods that are defined in the given file.
24 25 26 27 28 29 30 31 |
# File 'sorbet/tapioca/utils.rb', line 24 def self.methods_from_file(mod, file_name, class_methods: false) methods = if class_methods mod.methods(false).map { mod.method(_1) } else mod.instance_methods(false).map { mod.instance_method(_1) } end methods.select { _1.source_location&.first&.end_with?(file_name) } end |
.named_object_for(klass) ⇒ Module
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.
8 9 10 11 12 13 14 15 16 |
# File 'sorbet/tapioca/utils.rb', line 8 def self.named_object_for(klass) return klass if klass.name attached_object = klass.attached_object case attached_object when Module then attached_object else raise "Unsupported attached object for: #{klass}" end end |
.named_objects_with_module(mod) ⇒ Array<Module>
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.
34 35 36 37 38 39 40 41 42 |
# File 'sorbet/tapioca/utils.rb', line 34 def self.named_objects_with_module(mod) ObjectSpace.each_object(mod).map do |obj| case obj when Class then named_object_for(obj) when Module then obj else raise "Unsupported object: #{obj}" end end.uniq end |