Module: Jat::Plugins::BaseActiverecordPreloads::Preloader::ClassMethods
- Included in:
- Jat::Plugins::BaseActiverecordPreloads::Preloader
- Defined in:
- lib/jat/plugins/base/base_activerecord_preloads/lib/preloader.rb
Instance Method Summary collapse
Instance Method Details
#handlers ⇒ Object
15 16 17 |
# File 'lib/jat/plugins/base/base_activerecord_preloads/lib/preloader.rb', line 15 def handlers @handlers ||= [ActiverecordRelation, ActiverecordObject, ActiverecordArray].freeze end |
#preload(object, preloads) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/jat/plugins/base/base_activerecord_preloads/lib/preloader.rb', line 8 def preload(object, preloads) preload_handler = handlers.find { |handler| handler.fit?(object) } raise Error, "Can't preload #{preloads.inspect} to #{object.inspect}" unless preload_handler preload_handler.preload(object, preloads) end |