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
Post a Comment