Sha256: eab54ea1651c78930633bccb4116183cda78cc14bbb265d494f8d6821eee169c

Contents?: true

Size: 790 Bytes

Versions: 14

Compression:

Stored size: 790 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

        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

14 entries across 14 versions & 1 rubygems

Version Path
torque-postgresql-1.1.7 lib/torque/postgresql/associations/association.rb
torque-postgresql-2.0.3 lib/torque/postgresql/associations/association.rb
torque-postgresql-2.0.2 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.1.6 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.1.5 lib/torque/postgresql/associations/association.rb
torque-postgresql-2.0.1 lib/torque/postgresql/associations/association.rb
torque-postgresql-2.0.0 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.1.4 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.1.3 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.1.2 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.1.1 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.1.0 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.0.1 lib/torque/postgresql/associations/association.rb
torque-postgresql-1.0.0 lib/torque/postgresql/associations/association.rb