Class: Zm::Client::Base::Object
- Inherits:
-
Object
- Object
- Zm::Client::Base::Object
show all
- Defined in:
- lib/zm/client/base/object.rb
Overview
Abstract Class Provisionning Object
Direct Known Subclasses
Ace, Appointment, Zm::Client::Backup, MailboxObject, Contact, Cos, DataSource, DistributionList, Document, Domain, FilterRule, Folder, Identity, License, Message, MountPoint, MtaQueue, MtaQueueItem, SearchFolder, Server, Share, Signature, Tag, Task
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parent) {|_self| ... } ⇒ Object
Returns a new instance of Object.
10
11
12
13
|
# File 'lib/zm/client/base/object.rb', line 10
def initialize(parent)
@parent = parent
yield(self) if block_given?
end
|
Instance Attribute Details
Returns the value of attribute id.
8
9
10
|
# File 'lib/zm/client/base/object.rb', line 8
def id
@id
end
|
Returns the value of attribute name.
8
9
10
|
# File 'lib/zm/client/base/object.rb', line 8
def name
@name
end
|
Returns the value of attribute parent.
8
9
10
|
# File 'lib/zm/client/base/object.rb', line 8
def parent
@parent
end
|
Returns the value of attribute token.
8
9
10
|
# File 'lib/zm/client/base/object.rb', line 8
def token
@token
end
|
Instance Method Details
#clone {|obj| ... } ⇒ Object
23
24
25
26
27
28
|
# File 'lib/zm/client/base/object.rb', line 23
def clone
obj = super
obj.remove_instance_variable(:@id)
yield(obj) if block_given?
obj
end
|
52
53
54
55
|
# File 'lib/zm/client/base/object.rb', line 52
def inspect
keys_str = to_h.map { |k, v| "#{k}: #{v}" }.join(', ')
"#{self.class}:#{format('0x00%x', (object_id << 1))} #{keys_str}"
end
|
#instance_variables_map ⇒ Object
57
58
59
60
61
|
# File 'lib/zm/client/base/object.rb', line 57
def instance_variables_map
keys = instance_variables.dup
keys.delete(:@parent)
keys.map { |key| [key, instance_variable_get(key)] }
end
|
30
31
32
|
# File 'lib/zm/client/base/object.rb', line 30
def logger
@parent.logger
end
|
#recorded? ⇒ Boolean
15
16
17
|
# File 'lib/zm/client/base/object.rb', line 15
def recorded?
!@id.nil?
end
|
19
20
21
|
# File 'lib/zm/client/base/object.rb', line 19
def save!
recorded? ? modify! : create!
end
|
48
49
50
|
# File 'lib/zm/client/base/object.rb', line 48
def to_h
Hash[instance_variables_map]
end
|
44
45
46
|
# File 'lib/zm/client/base/object.rb', line 44
def to_s
inspect
end
|
#update_attribute(key, value) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/zm/client/base/object.rb', line 34
def update_attribute(key, value)
arrow_attr_sym = Utils.arrow_name_sym(key)
if value.respond_to?(:empty?) && value.empty?
remove_instance_variable(arrow_attr_sym) if instance_variable_get(arrow_attr_sym)
else
instance_variable_set(arrow_attr_sym, value)
end
end
|