Class: Zm::Client::ServersCollection

Inherits:
Base::AdminObjectsCollection show all
Defined in:
lib/zm/client/server/servers_collection.rb

Overview

Collection servers TODO: modifier l’héritage car SearchDirectoryRequest n’implémente pas le type Server

Constant Summary

Constants inherited from Base::ObjectsCollection

Base::ObjectsCollection::METHODS_MISSING_LIST

Instance Attribute Summary

Attributes inherited from Base::ObjectsCollection

#parent

Instance Method Summary collapse

Methods inherited from Base::AdminObjectsCollection

#attrs, #clear, #count, #find_by, #find_by_or_nil, #find_each, #ldap

Methods inherited from Base::ObjectsCollection

#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

#initialize(parent) ⇒ ServersCollection

Returns a new instance of ServersCollection.



8
9
10
11
12
13
# File 'lib/zm/client/server/servers_collection.rb', line 8

def initialize(parent)
  @child_class = Server
  @builder_class = ServersBuilder
  @service = nil
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zm::Client::Base::ObjectsCollection

Instance Method Details

#build_find_by(hash) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/zm/client/server/servers_collection.rb', line 22

def build_find_by(hash)
  soap_request = SoapElement.admin(SoapAdminConstants::GET_SERVER_REQUEST)
  node_server = SoapElement.create(SoapConstants::SERVER)
                           .add_attribute(SoapConstants::BY, hash.keys.first)
                           .add_content(hash.values.first)
  soap_request.add_node(node_server)
  soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma) unless @attrs.nil?
  soap_request
end

#build_queryObject



41
42
43
44
45
# File 'lib/zm/client/server/servers_collection.rb', line 41

def build_query
  soap_request = SoapElement.admin(SoapAdminConstants::GET_ALL_SERVERS_REQUEST)
  soap_request.add_attribute(SoapConstants::SERVICE, @service) unless @service.nil?
  soap_request
end

#find_by!(hash) ⇒ Object



15
16
17
18
19
20
# File 'lib/zm/client/server/servers_collection.rb', line 15

def find_by!(hash)
  entry = sac.invoke(build_find_by(hash))[:GetServerResponse][:server].first

  reset_query_params
  ServerJsnsInitializer.create(@parent, entry)
end

#make_queryObject



37
38
39
# File 'lib/zm/client/server/servers_collection.rb', line 37

def make_query
  sac.invoke(build_query)
end

#where(service) ⇒ Object



32
33
34
35
# File 'lib/zm/client/server/servers_collection.rb', line 32

def where(service)
  @service = service
  self
end