Module: ArLazyPreload::CollectionAssociation
- Defined in:
- lib/ar_lazy_preload/active_record/collection_association.rb
Overview
ActiveRecord::CollectionAssociation patch with a hook for lazy preloading
Instance Method Summary collapse
-
#ids_reader ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Details
#ids_reader ⇒ Object
rubocop:disable Metrics/AbcSize
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ar_lazy_preload/active_record/collection_association.rb', line 7 def ids_reader return super if owner.lazy_preload_context.blank? primary_key = reflection.association_primary_key.to_sym if loaded? target.map(&primary_key) elsif !target.empty? load_target.map(&primary_key) else @association_ids ||= reader.map(&primary_key) end end |