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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---