Sha256: 55625124bf77e9c48cd629631066bf3e4ba6065265809193fafb6ba38f24752c

Contents?: true

Size: 968 Bytes

Versions: 4

Compression:

Stored size: 968 Bytes

Contents

module ActiveLdap
  module Association
    module HasManyUtils
      private
      def collect_targets(requested_target_key, need_requested_targets=false)
        foreign_base_key = primary_key
        return [] if foreign_base_key.nil?

        requested_targets = @owner[@options[requested_target_key], true]

        components = requested_targets.reject(&:nil?)
        unless foreign_base_key == "dn"
          components = components.collect do |value|
            [foreign_base_key, value]
          end
        end

        if components.empty?
          targets = []
        elsif foreign_base_key == "dn"
          targets = foreign_class.find(components, find_options)
        else
          options = find_options(:filter => [:or, *components])
          targets = foreign_class.find(:all, options)
        end

        if need_requested_targets
          [targets, requested_targets]
        else
          targets
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
activeldap-0.10.0 lib/active_ldap/association/has_many_utils.rb
activeldap-0.9.0 lib/active_ldap/association/has_many_utils.rb
activeldap-1.0.0 lib/active_ldap/association/has_many_utils.rb
ruby-activeldap-0.8.3.1 lib/active_ldap/association/has_many_utils.rb