Class: Zm::Client::Base::AdminObjectsCollection
Overview
Collection AdminObjectsCollection
Constant Summary
ObjectsCollection::METHODS_MISSING_LIST
Instance Attribute Summary
#parent
Instance Method Summary
collapse
#all, #find, #first, #logger, #method_missing, #new, #order, #page, #per_page, #respond_to_missing?
Methods included from Inspector
#inspect, #instance_variables_map, #to_h, #to_s
Constructor Details
Returns a new instance of AdminObjectsCollection.
8
9
10
11
12
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 8
def initialize(parent)
@parent = parent
@persistent = false
reset_query_params
end
|
Instance Method Details
#attrs(*attributes) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 35
def attrs(*attributes)
attributes.flatten!
attributes.map! { |attr| attr.to_s.strip }
attributes.sort!
attributes.uniq!
attributes.delete_if { |attr| attr.nil? || attr.empty? }
return self if @attrs == attributes
@attrs = attributes
self
end
|
#build_query ⇒ Object
90
91
92
93
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 90
def build_query
SoapElement.admin(SoapAdminConstants::SEARCH_DIRECTORY_REQUEST)
.add_attributes(jsns)
end
|
56
57
58
59
60
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 56
def clear
ldap_filter.clear
reset_query_params
self
end
|
48
49
50
51
52
53
54
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 48
def count
reset_query_params
@count_only = SoapUtils::ON
json = make_query
@count_only = SoapUtils::OFF
json[:SearchDirectoryResponse][:num]
end
|
#find_by(hash) ⇒ Object
14
15
16
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 14
def find_by(hash)
find_by!(hash)
end
|
#find_by_or_nil(hash, error_handler = SoapError) ⇒ Object
18
19
20
21
22
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 18
def find_by_or_nil(hash, error_handler = SoapError)
find_by(hash)
rescue error_handler => _e
nil
end
|
#find_each(offset: 0, limit: 1_000, &block) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 62
def find_each(offset: 0, limit: 1_000, &block)
previous_persistent = @persistent.dup
@persistent = true
_attrs = @attrs
total = count
@attrs = _attrs
@offset = offset
@limit = limit
while @offset < total
build_response.each { |item| block.call(item) }
@offset += @limit
end
ldap_filter.clear
reset_query_params
@persistent = previous_persistent
end
|
24
25
26
27
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 24
def ldap
@apply_cos = SoapUtils::OFF
self
end
|
#make_query ⇒ Object
84
85
86
87
88
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 84
def make_query
response = sac.invoke(build_query)
clear unless @persistent
response
end
|
#where(ldap_query) ⇒ Object
29
30
31
32
33
|
# File 'lib/zm/client/base/admin_objects_collection.rb', line 29
def where(ldap_query)
ldap_filter.add(ldap_query)
self
end
|