Initialization of class when inhereted

Hi!

class BaseClass
def BaseClass.initialization_for_derived_class
@var = do_something
end
end

class DerivedClass < BaseClass
end

I’d like to initialize @var in DerivedClass. Is there some way to run
initialization_for_derived_class when inheriting BaseClass?

Alexander Ponomarchuk wrote:

Hi!

class BaseClass
def BaseClass.initialization_for_derived_class
@var = do_something
end
end

class DerivedClass < BaseClass
end

I’d like to initialize @var in DerivedClass. Is there some way to run
initialization_for_derived_class when inheriting BaseClass?

Yes. ri Class#inherited