Class: Zm::Client::Domain
- Inherits:
-
Base::AdminObject
- Object
- Base::Object
- Base::AdminObject
- Zm::Client::Domain
- Defined in:
- lib/zm/client/domain/domain.rb
Overview
objectClass: zimbraDomain
Constant Summary collapse
- INSTANCE_VARIABLE_KEYS =
i[name description zimbraDomainName zimbraDomainStatus zimbraId zimbraDomainType zimbraDomainDefaultCOSId zimbraGalAccountId zimbraPreAuthKey zimbraGalLdapBindDn zimbraGalLdapBindPassword zimbraGalLdapFilter zimbraGalLdapSearchBase zimbraGalLdapURL zimbraGalMode]
Instance Attribute Summary
Attributes inherited from Base::Object
#grantee_type, #id, #name, #parent, #token
Instance Method Summary collapse
- #accounts ⇒ Object
- #all_instance_variable_keys ⇒ Object
- #init_from_json(json) ⇒ Object
-
#initialize(parent) ⇒ Domain
constructor
A new instance of Domain.
- #to_h ⇒ Object
- #update!(hash) ⇒ Object
Methods inherited from Base::AdminObject
#soap_account_connector, #soap_admin_connector
Methods inherited from Base::Object
#arrow_name, #clone, #concat, #convert_json_string_value, #instance_variables_array, #instance_variables_hash, #recorded?, #save!, #to_s
Constructor Details
#initialize(parent) ⇒ Domain
Returns a new instance of Domain.
13 14 15 16 |
# File 'lib/zm/client/domain/domain.rb', line 13 def initialize(parent) super(parent) @grantee_type = 'dom'.freeze end |
Instance Method Details
#accounts ⇒ Object
42 43 44 |
# File 'lib/zm/client/domain/domain.rb', line 42 def accounts @accounts ||= AccountsCollection.new(self) end |
#all_instance_variable_keys ⇒ Object
24 25 26 |
# File 'lib/zm/client/domain/domain.rb', line 24 def all_instance_variable_keys INSTANCE_VARIABLE_KEYS end |
#init_from_json(json) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/zm/client/domain/domain.rb', line 46 def init_from_json(json) super(json) return unless json[:a].is_a? Array n_key = :n c_key = :_content at_key = '@' attrs = {} # TODO: definir ici le typage fort des attributs pour ne pas avoir # a faire des cases sur les class des attributs dans le code. json[:a].each do |a| k = "#{at_key}#{a[n_key]}".to_sym v = a[c_key] if !attrs[k].nil? attrs[k] = [attrs[k]] unless attrs[k].is_a?(Array) attrs[k].push(v) else attrs[k] = v end end attrs.each { |k, v| instance_variable_set(k, v) } end |
#to_h ⇒ Object
18 19 20 21 22 |
# File 'lib/zm/client/domain/domain.rb', line 18 def to_h hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }] hashmap.delete_if { |_, v| v.nil? } hashmap end |
#update!(hash) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/zm/client/domain/domain.rb', line 28 def update!(hash) sac.modify_domain(@id, hash) hash.each do |k, v| arrow_attr_sym = "@#{k}".to_sym if v.respond_to?(:empty?) && v.empty? self.remove_instance_variable(arrow_attr_sym) if self.instance_variable_get(arrow_attr_sym) else self.instance_variable_set(arrow_attr_sym, v) end end end |