Using the new eager load API from Rails 4 #722

Merged
merged 2 commits into from Jan 2, 2013

Projects

None yet

2 participants

@rafaelfranca
Collaborator

Closes #478

cc @josevalim

@josevalim josevalim and 1 other commented on an outdated diff Jan 2, 2013
lib/simple_form.rb
- autoload :FormBuilder, 'simple_form/form_builder'
- autoload :Helpers, 'simple_form/helpers'
- autoload :I18nCache, 'simple_form/i18n_cache'
- autoload :Inputs, 'simple_form/inputs'
- autoload :MapType, 'simple_form/map_type'
- autoload :Wrappers, 'simple_form/wrappers'
+ extend ActiveSupport::Autoload
+
+ autoload :Helpers
+ autoload :Wrappers
+
+ eager_autoload do
+ autoload :Components
+ autoload :ErrorNotification
+ autoload :FormBuilder
+ autoload :I18nCache
josevalim
josevalim Jan 2, 2013 Owner

It doesn't look like this needs to be eager loaded, as it is a dependency from other modules. Modules are usually dependencies and in general do not need to be autoloaded.

rafaelfranca
rafaelfranca Jan 2, 2013 Collaborator

You are right. Removed from the autoload list and added as explicit require on the dependent files.

Owner

:shipit:

@rafaelfranca rafaelfranca merged commit 259f850 into rails_4 Jan 2, 2013

1 check passed

default The Travis build passed
Details
@rafaelfranca rafaelfranca deleted the rails_4_eager_load branch Jan 2, 2013
Owner

Btw, I think this could be safely backported to the master branch. We just need to check in the railtie if config.eager_load_namespaces is not nil.

Collaborator

But the eager_load! method is not available on ActiveSupport::Autoload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment