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
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parent) {|_self| ... } ⇒ Object
Returns a new instance of Object.
11
12
13
14
15
|
# File 'lib/zm/client/base/object.rb', line 11
def initialize(parent)
@parent = parent
@use_builder = true
yield(self) if block_given?
end
|
Instance Attribute Details
#grantee_type ⇒ Object
Returns the value of attribute grantee_type.
9
10
11
|
# File 'lib/zm/client/base/object.rb', line 9
def grantee_type
@grantee_type
end
|
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
#arrow_name(name) ⇒ Object
80
81
82
83
84
|
# File 'lib/zm/client/base/object.rb', line 80
def arrow_name(name)
return name if name.to_s.start_with?('@')
"@#{name}"
end
|
#clone {|obj| ... } ⇒ Object
86
87
88
89
90
91
|
# File 'lib/zm/client/base/object.rb', line 86
def clone
obj = super
obj.remove_instance_variable(:@id)
yield(obj) if block_given?
obj
end
|
36
37
38
|
# File 'lib/zm/client/base/object.rb', line 36
def concat
instance_variables.map { |variable| instance_variable_get(variable) }
end
|
#convert_json_string_value(value) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/zm/client/base/object.rb', line 44
def convert_json_string_value(value)
return value unless value.is_a?(String)
return 0 if value == '0'
c = value.to_i
c.to_s == value ? c : value
end
|
#disable_builder ⇒ Object
17
18
19
20
|
# File 'lib/zm/client/base/object.rb', line 17
def disable_builder
@use_builder = false
self
end
|
#enable_builder ⇒ Object
22
23
24
25
|
# File 'lib/zm/client/base/object.rb', line 22
def enable_builder
@use_builder = true
self
end
|
#init_from_json(json) ⇒ Object
31
32
33
34
|
# File 'lib/zm/client/base/object.rb', line 31
def init_from_json(json)
@id = json[:id]
@name = json[:name]
end
|
#instance_variables_array(zcs_attrs) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/zm/client/base/object.rb', line 60
def instance_variables_array(zcs_attrs)
selected_attrs = zcs_attrs.map { |a| arrow_name(a).to_sym }
attrs_only_set = instance_variables & selected_attrs
arr = attrs_only_set.map do |name|
n = name.to_s[1..-1]
value = instance_variable_get(name)
[n, value]
end
multi_value = arr.select { |a| a.last.is_a?(Array) }
arr.reject! { |a| a.last.is_a?(Array) }
multi_value.each { |a| arr += a.last.map { |v| [a.first, v] } }
arr
end
|
#instance_variables_hash(zcs_attrs) ⇒ Object
76
77
78
|
# File 'lib/zm/client/base/object.rb', line 76
def instance_variables_hash(zcs_attrs)
Hash[instance_variables_array(zcs_attrs)]
end
|
93
94
95
|
# File 'lib/zm/client/base/object.rb', line 93
def logger
@parent.logger
end
|
#recorded? ⇒ Boolean
52
53
54
|
# File 'lib/zm/client/base/object.rb', line 52
def recorded?
!@id.nil?
end
|
56
57
58
|
# File 'lib/zm/client/base/object.rb', line 56
def save!
recorded? ? modify! : create!
end
|
40
41
42
|
# File 'lib/zm/client/base/object.rb', line 40
def to_s
concat.join(DOUBLEPOINT)
end
|
#use_builder? ⇒ Boolean
27
28
29
|
# File 'lib/zm/client/base/object.rb', line 27
def use_builder?
@use_builder
end
|