Class: Zm::Client::LdapFilter

Inherits:
Object
  • Object
show all
Includes:
Inspector
Defined in:
lib/zm/client/base/ldap_filter.rb

Instance Method Summary collapse

Methods included from Inspector

#inspect, #instance_variables_map, #to_h, #to_s

Constructor Details

#initialize(base_filter = nil) ⇒ LdapFilter

Returns a new instance of LdapFilter.



8
9
10
11
# File 'lib/zm/client/base/ldap_filter.rb', line 8

def initialize(base_filter = nil)
  @base_filter = base_filter
  @parts = []
end

Instance Method Details

#add(filter) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/zm/client/base/ldap_filter.rb', line 13

def add(filter)
  new_filter = stringify_filter(filter)
  return false if new_filter.nil? || @parts.include?(new_filter)

  @parts << new_filter
  true
end

#clearObject



21
22
23
# File 'lib/zm/client/base/ldap_filter.rb', line 21

def clear
  @parts.clear
end

#joinObject



25
26
27
28
29
30
31
32
# File 'lib/zm/client/base/ldap_filter.rb', line 25

def join
  arr = @parts.dup
  arr.unshift(@base_filter) unless @base_filter.nil?

  return arr.first if arr.length <= 1

  "(&#{arr.join})"
end