Is there a hook similar to Class#inherited that's triggered only after a Ruby class definition?

前端 未结 8 2147
无人共我
无人共我 2020-12-03 13:35

#inherited is called right after the class Foo statement. I want something that\'ll run only after the end statement that closes the c

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 14:33

    If you are willing to assume your Ruby implements ObjectSpaces, you could could look up all model instances after the fact, and then modify them appropriately. Google suggests http://phrogz.net/ProgrammingRuby/ospace.html

提交回复
热议问题