Class: AD::LDAP::SearchArgs

Inherits:
Hash
  • Object
show all
Defined in:
lib/ad-ldap/search_args.rb

Constant Summary collapse

LDAP_KEYS =
[
  :base, :filter, :attributes, :return_result, :attributes_only,
  :scope, :size
]

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ SearchArgs

Returns a new instance of SearchArgs.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ad-ldap/search_args.rb', line 13

def initialize(args)
  super()
  conditions = {}
  args.each do |key, value|
    if LDAP_KEYS.include?(key.to_sym)
      self[key.to_sym] = value
    else
      conditions[key.to_sym] = value
    end
  end
  if !self[:base]
    self[:base] = AD::LDAP.config.treebase
  end
  if !self[:filter] && (filters = self.build_filters(conditions))
    self[:filter] = filters ? filters.to_s : nil
  end
end