Monday, April 16, 2007

get classes of a class

  1. def get_all_subclasses_of(string)
  2. raise ArgumentError.new("#{string} is not an AR Class") if eval(string).class.ancestors
  3. .collect {|e| e.to_s.downcase}.include? ("ActiveRecord::Base")
  4. return ObjectSpace.subclasses_of(eval(string))
  5. end

No comments:

Post a Comment

Tell me what you think