# File lib/reactor/cm/attribute_group.rb, line 84 def primary_key_value "#{self.obj_class}.#{self.name}" end
class Reactor::Cm::AttributeGroup
Public Class Methods
create(obj_class, name, index=nil)
click to toggle source
Calls superclass method
# 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)
click to toggle source
# 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
Public Instance Methods
add_attributes(attributes)
click to toggle source
# File lib/reactor/cm/attribute_group.rb, line 52 def add_attributes(attributes) add_or_remove_attributes(attributes, 'add') end
identifier()
click to toggle source
# File lib/reactor/cm/attribute_group.rb, line 18 def identifier primary_key_value end
identifier=(val)
click to toggle source
# File lib/reactor/cm/attribute_group.rb, line 22 def identifier=(val) primary_key_value_set(val) end
move_attribute(attribute, index)
click to toggle source
# 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)
click to toggle source
# File lib/reactor/cm/attribute_group.rb, line 56 def remove_attributes(attributes) add_or_remove_attributes(attributes, 'remove') end
set(attr, value)
click to toggle source
# File lib/reactor/cm/attribute_group.rb, line 79 def set(attr, value) self.send(:"#{attr}=", value) end
Protected Instance Methods
add_or_remove_attributes(attributes, add_or_remove)
click to toggle source
# File lib/reactor/cm/attribute_group.rb, line 94 def add_or_remove_attributes(attributes, add_or_remove) request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, primary_key, primary_key_value) xml.tag!("#{base_name}-#{add_or_remove}Attributes") do attributes.each do |attribute| xml.tag!('listitem') do xml.text!(attribute) end end end end response = request.execute! response.ok? && reload end
primary_key_value()
click to toggle source
primary_key_value_set(value)
click to toggle source
# File lib/reactor/cm/attribute_group.rb, line 88 def primary_key_value_set(value) a = value.split('.') self.obj_class = a.first self.name = a.last end