Sha256: ca72a09e99e8b90e18c4ce1a4464399bcf9aa2e704588a573d18b967b6af71f2

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

module Torque
  module PostgreSQL
    module Associations
      module Association

        def inversed_from(record)
          return super unless reflection.connected_through_array?

          self.target ||= []
          self.target.push(record) unless self.target.include?(record)
          @inversed = self.target.present?
        end

        def skip_statement_cache?(*)
          super || reflection.connected_through_array?
        end

        private

          def set_owner_attributes(record)
            return super unless reflection.connected_through_array?

            add_id = owner[reflection.active_record_primary_key]
            record_fk = reflection.foreign_key

            record[record_fk].push(add_id) unless (record[record_fk] ||= []).include?(add_id)
          end

      end

      ::ActiveRecord::Associations::Association.prepend(Association)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
torque-postgresql-1.1.8 lib/torque/postgresql/associations/association.rb