vendredi 29 mai 2015

Ruby : Dynamic Inheritance

I have two base class and multiple child class.. Based on the type, the child class dynamically inherit from the base parent class.

Eg:

 class Dad
     def initialize
         #initialize some stuffs
     end
 end

 class Mom 
     def initialize
         #initialize some stuffs
     end     
 end

 class child
 def initialize
        super
        #initialize some stuffs
     end
 end

 class child2
     def initialize
       super
       #initialize some stuffs
     end     
 end

 class child3
 end

How to assign parent class to child class dynamically?

Aucun commentaire:

Enregistrer un commentaire