Ruby inherited callback runs before subclass is loaded by jgn on Tuesday, September 22, 2009 in Technology

Harrumph.

I wanted to call a class method on a subclass when the base class's inherited callback is triggered.

But it doesn't work, because the subclass isn't loaded when this callback is triggered.

:-(

So the following doesn't work ('boo' prints instead of 'foo'):

[source language='ruby'] class Base def self.permalink 'boo' end def self.inherited(c) puts "permalink: #{c.permalink}" end end

class C

comments powered by Disqus