Using ActiveSupport's autoload_at

After discovering

I thought
it’d be nice if we could replace our zillion occurences of:

autoload :Something, ‘some_path/something’

with:

autoload_at ‘some_path’ do
autoload :Something
end

But I keep getting undefined method autoload_at. I tried digging -
ActionSupport::Autoload is being loaded by the time it reaches the above
line (I tested by putting a puts ‘loaded’ in
activesupport/lib/active_support/dependencies/autoload.rb and it worked,
and also require ‘active_support/dependencies/autoload’ returned false.

I can only guess that while that file is being loaded, the methods it
defined aren’t replacing Kernel’s default autoloading support. I could
try using “extend ActiveSupport::Autoload”, but I don’t want to do this
in every single file that uses autoloading (as mentioned above, our
project has a bunch of such files)

I also wasn’t able to find any online guides on docs on how to use
autoload_at, except the above API link.

Could someone help me with this please? Or is the activesupport’s
autoload library not intended for public use to begin with?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs