Module: Para::Sti::RootModel::ClassMethods
- Defined in:
- lib/para/sti/root_model.rb
Instance Method Summary collapse
Instance Method Details
#eager_load! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/para/sti/root_model.rb', line 18 def eager_load! return if @eager_loaded @eager_loaded = true models_dir = Rails.root.join('app', 'models') Dir[models_dir.join(subclasses_dir, '*.rb')].each do |file_path| file_name = File.basename(file_path, '.rb') # Avoid Circular dependecy errors in development, when the first # loaded class is not the base class. In this case, the base class # loading is triggered by the child, so if we try to load that child # again, Rails issues a CircularDependency error file_load_path = File.join(File.dirname(file_path), file_name) next if ActiveSupport::Dependencies.loading.include?(file_load_path) # Autoload the subclass require file_load_path end end |