I would find this useful. I wanted something like this just recently. Brian
On Fri, Jan 22, 2016 at 1:22 AM, Mario Visic <[email protected]> wrote: > Hi all > > I work on some fairly large ruby on rails applications and boot up time in > development always starts to become an issue, using a preloader like zeus > or spring helps but reducing the first boot time is always useful. One of > the big slowdowns for booting these large apps usually turns out to be > initializers touching constants which then triggers an autoload. There is a > popular pattern used where the class definition and configuration are split > up into two, you then end up with a file in config/initializers which will > run something like: MyClass.configure, which then triggers MyClass to be > defined and slows down the boot process. > > It would be nice instead to be able to run the configuration code when the > constant gets autoloaded, something like this: > > ActiveSupport::Dependencies.on_load('MyClass') do > MyClass.configure do |config| > # config here > end > end > > That way we still have the benefit of splitting up the class definition > and the configuration, but we aren't eagerly loading the class in the > initializer, only later when it's needed. > > I've written a small patch which implements this behaviour: > https://github.com/mariovisic/rails/commit/b5ecbf36fa087c59e716e1e85eb05a5bcb658e29 > As you can see the logic is only a few lines. > > Does anyone have any thoughts on if this patch would be useful to others? > > Cheers > Mario > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
