Sha256: d50a06e9549423ef5483271ef91252adc15a815cbef6c27f2df6891503ba72df

Contents?: true

Size: 1.97 KB

Versions: 622

Compression:

Stored size: 1.97 KB

Contents

# frozen_string_literal: true
# typed: true

module T::Private::Abstract::Hooks
  # This will become the self.extend_object method on a module that extends Abstract::Hooks.
  # It gets called when *that* module gets extended in another class/module (similar to the
  # `extended` hook, but this gets calls before the ancestors of `other` get modified, which
  # is important for our validation).
  private def extend_object(other)
    T::Private::Abstract::Data.set(self, :last_used_by, other)
    super
  end

  # This will become the self.append_features method on a module that extends Abstract::Hooks.
  # It gets called when *that* module gets included in another class/module (similar to the
  # `included` hook, but this gets calls before the ancestors of `other` get modified, which
  # is important for our validation).
  private def append_features(other)
    T::Private::Abstract::Data.set(self, :last_used_by, other)
    super
  end

  # This will become the self.inherited method on a class that extends Abstract::Hooks.
  # It gets called when *that* class gets inherited by another class.
  private def inherited(other)
    super
    # `self` may not actually be abstract -- it could be a concrete class that inherited from an
    # abstract class. We only need to check this in `inherited` because, for modules being included
    # or extended, the concrete ones won't have these hooks at all. This is just an optimization.
    return if !T::AbstractUtils.abstract_module?(self)

    T::Private::Abstract::Data.set(self, :last_used_by, other)
  end

  # This will become the self.prepended method on a module that extends Abstract::Hooks.
  # It will get called when *that* module gets prepended in another class/module.
  private def prepended(other)
    # Prepending abstract methods is weird. You'd only be able to override them via other prepended
    # modules, or in subclasses. Punt until we have a use case.
    Kernel.raise "Prepending abstract mixins is not currently supported."
  end
end

Version data entries

622 entries across 616 versions & 3 rubygems

Version Path
sorbet-runtime-0.5.11834 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11829 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11826 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11823 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11820 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11813 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11812 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11810 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11805 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11802 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11801 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11798 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11796 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11789 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11787 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11784 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11781 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11780 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11778 lib/types/private/abstract/hooks.rb
sorbet-runtime-0.5.11770 lib/types/private/abstract/hooks.rb