Subclasses_of core method

class Account < ActiveRecord::Base

Catch-all for methods like is_admin_or_operator.

def method_missing(method_name, *arguments)
return super unless method_name.to_s =~ /\Ais_/
subclasses_for_scan =
Regexp.union(*Object.subclasses_of(Account).map { |c|
c.name.downcase })
klasses = method_name.to_s.scan(subclasses_for_scan)
klasses.include?(self.class.to_s.downcase)
end

hello.
I’m trying to use the above code but I have a problem with
subclasses_of, returning random results, probably because of model
load order.

is there a stable way to fetch every subclass of Account without
including every subclass in the same file or by parsing model source
files?
also I would like to move subclasses_for_scan implementation outside
this method, to make only one call.

thanks.