Class: Ontrac::WebServices::Definitions::DefinitionBase

Inherits:
Struct
  • Object
show all
Defined in:
lib/ontrac/web_services/definitions.rb

Instance Method Summary collapse

Constructor Details

#initializeDefinitionBase

Returns a new instance of DefinitionBase.



5
6
7
# File 'lib/ontrac/web_services/definitions.rb', line 5

def initialize(*)
  super
end

Instance Method Details

#to_xml(root_name = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ontrac/web_services/definitions.rb', line 9

def to_xml(root_name = nil)
  xml_builder = Nokogiri::XML::Builder.new
  root_name ||= self.class.name.split("::").last

  xml_builder.send(root_name) do |xml|
    members.each do |field|
      value = send(field)
      if (DefinitionBase === value)
        xml.doc.root << value.to_xml(field)
      else
        xml.send(field, value) unless (value.nil?)
      end
    end
  end

  xml_builder.doc.root
end