Module: T::Private::Final
- Defined in:
- lib/types/private/final.rb
Overview
typed: false
Defined Under Namespace
Modules: NoIncludeExtend, NoInherit
Class Method Summary collapse
Class Method Details
.declare(mod) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/types/private/final.rb', line 24 def self.declare(mod) if !mod.is_a?(Module) raise "#{mod.inspect} is not a class or module and cannot be declared as final with `final!`" end if final_module?(mod) raise "#{mod.name} was already declared as final and cannot be re-declared as final" end if T::AbstractUtils.abstract_module?(mod) raise "#{mod.name} was already declared as abstract and cannot be declared as final" end mod.extend(mod.is_a?(Class) ? NoInherit : NoIncludeExtend) mark_as_final_module(mod) mark_as_final_module(mod.singleton_class) T::Private::Methods.add_module_with_final(mod) T::Private::Methods.install_hooks(mod) end |
.final_module?(mod) ⇒ Boolean
41 42 43 |
# File 'lib/types/private/final.rb', line 41 def self.final_module?(mod) mod.instance_variable_defined?(:@sorbet_final_module) end |