Sha256: 711b310ec59f2964bd745b2cb287b8a09606812ffd97df28a8825de22f1fe40c
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require 'active_record/associations/builder/association' require 'active_record/associations/preloader/association' module ActiveRecord module Associations module Builder class Association #:nodoc: self.extensions << ActiveRecordAssociationQueryEconomizer::AssociationExtension.new end end class Preloader class Association #:nodoc: def preload_filters [reflection.options[:preload_if]].flatten.compact end def owners_filtered unless defined?(@owners_filtered) @owners_filtered = owners.dup preload_filters.each do |filter| case filter when Proc @owners_filtered.select!(&filter) when Symbol @owners_filtered.select! { |record| record.send(filter) } end end end @owners_filtered end remove_method :owner_keys def owner_keys unless defined?(@owner_keys) @owner_keys = owners_filtered.map do |owner| owner[owner_key_name] end @owner_keys.uniq! @owner_keys.compact! end @owner_keys end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems