Class: Reactor::Cm::AttributeGroup
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ObjectBase
#base_name, base_name, #delete, #delete!, delete!, get, inherited, #initialize, #reload, #save, #save!, serialize_attribute_to_xml, #serialize_attribute_to_xml, set_base_name
Class Method Details
.create(obj_class, name, index = nil) ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/reactor/cm/attribute_group.rb', line 41
def self.create(obj_class, name, index=nil)
pk = [obj_class, name].join('.')
attributes = {
objClass: obj_class,
name: name
}
attributes[:index] = index if index
super(pk, attributes)
end
|
.exists?(pk_val) ⇒ Boolean
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/reactor/cm/attribute_group.rb', line 26
def self.exists?(pk_val)
request = XmlRequest.prepare do |xml|
xml.where_key_tag!(base_name, primary_key, pk_val)
xml.get_key_tag!(base_name, :name)
end
response = request.execute!
return response.ok?
rescue XmlRequestError => e
return false
end
|
Instance Method Details
#add_attributes(attributes) ⇒ Object
52
53
54
|
# File 'lib/reactor/cm/attribute_group.rb', line 52
def add_attributes(attributes)
add_or_remove_attributes(attributes, 'add')
end
|
#identifier ⇒ Object
18
19
20
|
# File 'lib/reactor/cm/attribute_group.rb', line 18
def identifier
primary_key_value
end
|
#identifier=(val) ⇒ Object
22
23
24
|
# File 'lib/reactor/cm/attribute_group.rb', line 22
def identifier=(val)
primary_key_value_set(val)
end
|
#move_attribute(attribute, index) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/reactor/cm/attribute_group.rb', line 60
def move_attribute(attribute, index)
request = XmlRequest.prepare do |xml|
xml.where_key_tag!(base_name, primary_key, primary_key_value)
xml.tag!("#{base_name}-moveAttribute") do
xml.tag!('attribute') do
xml.text!(attribute.to_s)
end
xml.tag!('index') do
xml.text!(index.to_s)
end
end
end
response = request.execute!
response.ok? && reload
end
|
#remove_attributes(attributes) ⇒ Object
56
57
58
|
# File 'lib/reactor/cm/attribute_group.rb', line 56
def remove_attributes(attributes)
add_or_remove_attributes(attributes, 'remove')
end
|
#set(attr, value) ⇒ Object
79
80
81
|
# File 'lib/reactor/cm/attribute_group.rb', line 79
def set(attr, value)
self.send(:"#{attr}=", value)
end
|