Class: AutoPreload::Adapters::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_preload/adapters/active_record.rb

Overview

This class takes a model and finds all the preloadable associations.

Instance Method Summary collapse

Instance Method Details

#resolve_preloadables(model, _options = {}) ⇒ Array<ActiveRecord::Reflection>

Returns The preloadable associations.

Parameters:

  • model (ActiveRecord::Base)

Returns:

  • (Array<ActiveRecord::Reflection>)

    The preloadable associations.



9
10
11
12
13
14
15
# File 'lib/auto_preload/adapters/active_record.rb', line 9

def resolve_preloadables(model, _options = {})
  if model.auto_preloadable
    model.auto_preloadable.map { |w| model.reflect_on_association(w) }.compact
  else
    model.reflect_on_all_associations
  end
end