lib/usable/railtie.rb in usable-3.6.1 vs lib/usable/railtie.rb in usable-3.6.2
- old
+ new
@@ -1,6 +1,13 @@
class Usable::Railtie < Rails::Railtie
config.usable_config = Struct.new(:frozen).new(false)
- config.after_initialize do |app|
- Usable.freeze if app.config.usable_config.frozen
+
+ # This was the only way to consistently hook into the end of the Rails eager load process. The +after_initialize+ hook works great, except when
+ # +Rails.application.eager_load!+ is called directly from a third-party gem (e.g. Resque rake task), in which case the order is not guaranteed.
+ # The solution instead is to overload +eager_load!+
+ initializer 'usable' do |app|
+ if app.config.usable_config.frozen
+ require 'usable/eager_load'
+ app.class.prepend Usable::EagerLoad
+ end
end
end