Sha256: e345574fca44be02cb75f3eaaa2f9a28eb927ad283ee8b025d3bc225a6a4b1a4

Contents?: true

Size: 571 Bytes

Versions: 2

Compression:

Stored size: 571 Bytes

Contents

module CompositePrimaryKeys
  module CollectionAssociation
    extend ActiveSupport::Concern
    included do
      def get_records_with_cpk_support
        cpk_applies = (target && target.respond_to?(:composite?) && target.composite?) || (owner && owner.respond_to?(:composite?) && owner.composite?)
        return scope.to_a if cpk_applies
        get_records_without_cpk_support
      end
      alias_method_chain :get_records, :cpk_support
    end
  end
end

ActiveRecord::Associations::CollectionAssociation.send(:include, CompositePrimaryKeys::CollectionAssociation)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
composite_primary_keys-8.1.0 lib/composite_primary_keys/associations/collection_association.rb
composite_primary_keys-8.0.0 lib/composite_primary_keys/associations/collection_association.rb