Sha256: 551c7a832b2f5b94bc82a932565574955e16802813faf9c90519ba4bca160bbc

Contents?: true

Size: 759 Bytes

Versions: 6

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  class AssociationRelation < Relation
    def initialize(klass, association)
      super(klass)
      @association = association
    end

    def proxy_association
      @association
    end

    def ==(other)
      other == records
    end

    def build(*args, &block)
      scoping { @association.build(*args, &block) }
    end
    alias new build

    def create(*args, &block)
      scoping { @association.create(*args, &block) }
    end

    def create!(*args, &block)
      scoping { @association.create!(*args, &block) }
    end

    private

      def exec_queries
        super do |r|
          @association.set_inverse_instance r
          yield r if block_given?
        end
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-5.2.1.1 lib/active_record/association_relation.rb
activerecord-5.2.1 lib/active_record/association_relation.rb
activerecord-5.2.1.rc1 lib/active_record/association_relation.rb
activerecord-5.2.0 lib/active_record/association_relation.rb
activerecord-5.2.0.rc2 lib/active_record/association_relation.rb
activerecord-5.2.0.rc1 lib/active_record/association_relation.rb