I have set up two classes as shown below
class Parent
def self.inherited(child)
child.custom_class_method
end
def self.custom_class_method
raise "You haven't implemented me yet!"
end
end
class Child < Parent
def self.custom_class_method
"hello world"
end
end
It seems that when the inheritence Child < Parent is evaluated, it calls self.inherited, which in turn raises the Parent's version of self.custom_class_method instead of the Child's. This is a problem because instead of getting an expected "hello world" I get an error raised saying "You haven't implemented me yet!"
Does Child's self.custom_class_method not get evaluated until after Parent's self.inherited is finished evaluating? And if so is there perhaps a work around this? Should I just not put a raise check on the Parent class?
custom_class_methodshould be to call onsuper. Otherwise, just calledChild.custom_class_methodshould result in your "hello world" output. Could you please provide deeper logging?irbconsole. It errors out when evaluating theChildclass because of this very reason.