Method: FeatureEnvy::FinalClass.extended

Defined in:
lib/feature_envy/final_class.rb

.extended(final_class) ⇒ Object

Raises:



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/feature_envy/final_class.rb', line 71

def extended final_class
  # The class must be marked final first, before we check whether there
  # are already existing subclasses. If the error were raised first then
  # .final? would return +false+ causing confusion: if the class isn't
  # final then why was the error raised?
  @classes << final_class

  subclasses = Internal.subclasses final_class
  return if subclasses.empty?

  raise Error.new(final_class:, subclasses:)
end