Class: Reactor::Cm::Attribute
- Inherits:
-
Object
- Object
- Reactor::Cm::Attribute
- Defined in:
- lib/reactor/cm/attribute.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create(name, type) ⇒ Object
24 25 26 27 28 |
# File 'lib/reactor/cm/attribute.rb', line 24 def self.create(name, type) attr = Attribute.new attr.send(:create, name, type) attr end |
.exists?(name) ⇒ Boolean
4 5 6 7 8 9 10 |
# File 'lib/reactor/cm/attribute.rb', line 4 def self.exists?(name) begin Attribute.new.send(:get, name).ok? rescue StandardError false end end |
.get(name) ⇒ Object
18 19 20 21 22 |
# File 'lib/reactor/cm/attribute.rb', line 18 def self.get(name) attr = Attribute.new attr.send(:get, name) attr end |
.instance(name) ⇒ Object
12 13 14 15 16 |
# File 'lib/reactor/cm/attribute.rb', line 12 def self.instance(name) attr = Attribute.new attr.instance_variable_set("@name", name) attr end |
Instance Method Details
#delete! ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/reactor/cm/attribute.rb', line 46 def delete! request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, "name", @name) xml.tag!("#{base_name}-delete") end request.execute! end |
#save! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/reactor/cm/attribute.rb', line 34 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 request.execute! end |
#set(key, value) ⇒ Object
30 31 32 |
# File 'lib/reactor/cm/attribute.rb', line 30 def set(key, value) @params[key.to_sym] = value end |