setup settings send to its parent class in ruby -


how can write (child) class so:

class child < parent   create_columns :name, :address end  that:  class parent # can access create_columns set child class? end 

thanks.

you can solve using inherited hook method in ruby, can track children.

class parent  self.inherited(base)     self.children << base   end end  class child < parent def initialize   @@instances << self end  def self.instances   @@instances end 

now can things parent.children.each { |child| child.instances.collect(:&name) }. if name accessable :-)

hope helps!


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -