Created
April 6, 2009 03:10
-
-
Save davidlee/90626 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MetaLoader | |
def load_all_controllers | |
@controller_files = [] | |
Find.find( File.join( RAILS_ROOT, 'app/controllers' )) do |fn| | |
next unless fn =~ /_controller.rb$/ | |
# begin | |
@controller_files << fn | |
require( fn ) | |
# rescue Exception => e | |
# puts "FAILED: #{fn} #{e}" | |
# end | |
end | |
@controller_files | |
end | |
def find_all_controller_classes | |
load_all_controllers() | |
@controller_classes = [] | |
ObjectSpace.each_object do |o| | |
next unless o.class == Class && o.respond_to?(:ancestors) | |
@controller_classes << o if o.ancestors.include?( ApplicationController ) | |
end | |
@controller_classes | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment