Sha256: 54116f2b1ef66303fc3ea033f455a8f802742eef80034c897813e62fe10cefe5

Contents?: true

Size: 804 Bytes

Versions: 35

Compression:

Stored size: 804 Bytes

Contents

require 'active_ldap/association/collection'
require 'active_ldap/association/has_many_utils'

module ActiveLdap
  module Association
    class HasMany < Collection
      include HasManyUtils

      private
      def insert_entry(entry)
        entry[foreign_key] = @owner[primary_key]
        entry.save
      end

      def find_target
        collect_targets(primary_key)
      end

      def delete_entries(entries)
        _foreign_key = foreign_key
        components = @owner[primary_key, true].reject do |value|
          value.nil?
        end
        filter = [:and,
                  [:and, {_foreign_key => components}],
                  [:or, {foreign_class.dn_attribute => entries.collect(&:id)}]]
        foreign_class.update_all({_foreign_key => []}, filter)
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
activeldap-4.0.4 lib/active_ldap/association/has_many.rb
activeldap-4.0.3 lib/active_ldap/association/has_many.rb
activeldap-4.0.2 lib/active_ldap/association/has_many.rb
activeldap-4.0.1 lib/active_ldap/association/has_many.rb
activeldap-4.0.0 lib/active_ldap/association/has_many.rb
activeldap-3.2.2 lib/active_ldap/association/has_many.rb
activeldap-3.2.1 lib/active_ldap/association/has_many.rb
activeldap-3.2.0 lib/active_ldap/association/has_many.rb
activeldap-3.1.1 lib/active_ldap/association/has_many.rb
activeldap-3.1.0 lib/active_ldap/association/has_many.rb
activeldap-1.2.4 lib/active_ldap/association/has_many.rb
activeldap-1.2.3 lib/active_ldap/association/has_many.rb
activeldap3-1.2.3 lib/active_ldap/association/has_many.rb
activeldap-1.2.2 lib/active_ldap/association/has_many.rb
activeldap-1.2.1 lib/active_ldap/association/has_many.rb