New classes on inheritance

I’m trying to create a new globally available subclass upon the
inheritance of another class. This code isn’t close to complete, but I
think I’m on the right track.

class PersonHelper; end

class Person
def self.inherited(klass)
helper = Object.const_get(klass.to_s + ‘Helper’)
# define class here?
end
end

class Employee < Person; end

Basically, I’m trying to accomplish this:

class EmployeeHelper < PersonHelper; end

…by defining class Employee. Any help would be appreciated. Thanks in
advance!

On Jan 25, 2008 3:00 PM, Jeff T. [email protected] wrote:

I’m trying to create a new globally available subclass upon the
inheritance of another class. This code isn’t close to complete, but I
think I’m on the right track.

class PersonHelper; end

class Person
def self.inherited(klass)
helper = Object.const_get(klass.to_s + ‘Helper’)
Instead try:
const_set(klass.to_s + ‘Helper’, class.new(PersonHelper))

  # define class here?

yes :slight_smile:

klass.class_eval do

end