Last active
September 24, 2022 16:10
-
-
Save aantix/42480a662f2c777a24b43eb1694725dc to your computer and use it in GitHub Desktop.
Getting all Rails application level classes and modules
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
Zeitwerk::Loader.eager_load_all && true | |
objs = [] | |
ObjectSpace.each_object(Module){|ob| objs << [ob, ((Object.const_source_location(ob.to_s) rescue nil) || (Module.const_source_location(ob.to_s) rescue nil))]} | |
objs.reject!{|o| !(o&.last&.first =~ /#{Rails.root.to_s}/)} | |
objs = objs.collect{|c| c.flatten.first} | |
objs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment