Class: Reactor::Cm::Job

Inherits:
ObjectBase show all
Defined in:
lib/reactor/cm/job.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ObjectBase

#base_name, base_name, #delete, #delete!, delete!, exists?, get, inherited, #initialize, #reload, #save, #save!, #serialize_attribute_to_xml, set_base_name

Constructor Details

This class inherits a constructor from Reactor::Cm::ObjectBase

Class Method Details

.create(pk_value, attributes = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/reactor/cm/job.rb', line 44

def self.create(pk_value, attributes = {})
  request = XmlRequest.prepare do |xml|
    xml.create_tag!(base_name) do
      attributes.merge(name: pk_value).each do |attr_name, attr_value|
        serialize_attribute_to_xml(xml, xml_attribute(attr_name), attr_value)
      end
    end
  end

  request.execute!

  get(pk_value)
end

.serialize_attribute_to_xml(xml, xml_attribute, value) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/reactor/cm/job.rb', line 19

def self.serialize_attribute_to_xml(xml, xml_attribute, value)
  if xml_attribute.type.to_sym == :schedule
    xml.tag!("schedule") do
      (value || []).each do |schedule_entry|
        xml.tag!("listitem") do
          schedule_entry.each do |dim, values|
            xml.tag!("dictitem") do
              xml.tag!("key") do
                xml.text!(dim.to_s)
              end
              xml.tag!("value") do
                values.each do |val|
                  xml.tag!("listitem", val)
                end
              end
            end
          end
        end
      end
    end
  else
    super(xml, xml_attribute, value)
  end
end

Instance Method Details

#cancelObject



62
63
64
# File 'lib/reactor/cm/job.rb', line 62

def cancel
  simple_command("cancel")
end

#execObject



58
59
60
# File 'lib/reactor/cm/job.rb', line 58

def exec
  simple_commnad("exec")
end