Sha256: 4e1db45aae47069855e548cc54a1ad8dd68078ec28f0a77e259ce7bc8dab2840

Contents?: true

Size: 815 Bytes

Versions: 7

Compression:

Stored size: 815 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[primary_key] = @owner[@options[:foreign_key_name]]
        entry.save
      end

      def find_target
        collect_targets(:foreign_key_name)
      end

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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
activeldap-1.0.0 lib/active_ldap/association/has_many.rb
activeldap-0.10.0 lib/active_ldap/association/has_many.rb
activeldap-0.9.0 lib/active_ldap/association/has_many.rb
activeldap-1.0.9 lib/active_ldap/association/has_many.rb
activeldap-1.0.1 lib/active_ldap/association/has_many.rb
activeldap-1.0.2 lib/active_ldap/association/has_many.rb
ruby-activeldap-0.8.3.1 lib/active_ldap/association/has_many.rb