ruby - Callback for classes defined inside a Module -


ruby has several built-in callbacks. there callback such case? kinda method_added, classes (or constants) inside module, instead of instance methods inside class.

as far know, there nothing you're describing. however, here's how create own, using class::inherited.

module mymodule   def self.class_added(klass)     # ... handle   end   class ::class     alias_method :old_inherited, :inherited     def inherited(subclass)       mymodule.class_added(subclass) if /^mymodule::\w+/.match subclass.name       old_inherited(subclass)     end   end end  module mymodule   # add classes end 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -