Class: LDAP::Filter::Compound

Inherits:
Object
  • Object
show all
Defined in:
lib/ldap/filter/compound.rb

Direct Known Subclasses

AndFilter, OrFilter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operator, key_or_mappings, *values) ⇒ Compound

Returns a new instance of Compound.



7
8
9
10
11
12
13
14
# File 'lib/ldap/filter/compound.rb', line 7

def initialize operator, key_or_mappings, *values
  @children = case key_or_mappings
              when Symbol then populate_from_values key_or_mappings, values
              when Array then grep key_or_mappings
              when Hash then populate_from_hash key_or_mappings
              end
  @operator = operator unless @operator
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



5
6
7
# File 'lib/ldap/filter/compound.rb', line 5

def children
  @children
end

#operatorObject (readonly)

Returns the value of attribute operator.



5
6
7
# File 'lib/ldap/filter/compound.rb', line 5

def operator
  @operator
end

Instance Method Details

#&(filter) ⇒ Object



32
33
34
# File 'lib/ldap/filter/compound.rb', line 32

def & filter
  AndFilter.new [self, filter]
end

#<<(filter) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
# File 'lib/ldap/filter/compound.rb', line 23

def << filter
  raise ArgumentError, 'invalid representation of a filter' unless valid_filter?(filter)
  @children << filter
end

#to_sObject



16
17
18
19
20
21
# File 'lib/ldap/filter/compound.rb', line 16

def to_s
  filter = '('
  filter << @operator.to_s
  filter << @children.map(&:to_s).join
  filter << ')'
end

#|(filter) ⇒ Object



28
29
30
# File 'lib/ldap/filter/compound.rb', line 28

def | filter
  OrFilter.new [self, filter]
end