Class: Reactor::Cm::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/reactor/cm/attribute.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(name, type) ⇒ Object



25
26
27
28
29
# File 'lib/reactor/cm/attribute.rb', line 25

def self.create(name, type)
  attr = Attribute.new
  attr.send(:create,name,type)
  attr
end

.exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
# File 'lib/reactor/cm/attribute.rb', line 5

def self.exists?(name)
  begin
    return Attribute.new.send(:get,name).ok?
  rescue
    return false
  end
end

.get(name) ⇒ Object



19
20
21
22
23
# File 'lib/reactor/cm/attribute.rb', line 19

def self.get(name)
  attr = Attribute.new
  attr.send(:get,name)
  attr
end

.instance(name) ⇒ Object



13
14
15
16
17
# File 'lib/reactor/cm/attribute.rb', line 13

def self.instance(name)
  attr = Attribute.new
  attr.instance_variable_set('@name', name)
  attr
end

Instance Method Details

#delete!Object



47
48
49
50
51
52
53
# File 'lib/reactor/cm/attribute.rb', line 47

def delete!
  request = XmlRequest.prepare do |xml|
    xml.where_key_tag!(base_name, 'name', @name)
    xml.tag!("#{base_name}-delete")
  end
  response = request.execute!
end

#save!Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/reactor/cm/attribute.rb', line 35

def save!
  request = XmlRequest.prepare do |xml|
    xml.where_key_tag!(base_name, 'name', @name)
    xml.set_tag!(base_name) do
      @params.each do |key, value|
        xml.value_tag!(key.to_s, value)
      end
    end
  end
  response = request.execute!
end

#set(key, value) ⇒ Object



31
32
33
# File 'lib/reactor/cm/attribute.rb', line 31

def set(key, value)
  @params[key.to_sym] = value
end