Module: OM::XML::Container

Defined in:
lib/om/xml/container.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ng_xmlObject

Returns the value of attribute ng_xml.



3
4
5
# File 'lib/om/xml/container.rb', line 3

def ng_xml
  @ng_xml
end

Class Method Details

.included(klass) ⇒ Object

Instance Methods – These methods will be available on instances of classes that include this module



31
32
33
# File 'lib/om/xml/container.rb', line 31

def self.included(klass)
  klass.extend(ClassMethods)
end

Instance Method Details

#to_xml(xml = ng_xml) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/om/xml/container.rb', line 35

def to_xml(xml = ng_xml)
  if xml == ng_xml
    return xml.to_xml
  elsif ng_xml.root.nil?
      return xml.to_xml
  elsif xml.kind_of?(Nokogiri::XML::Document)
      xml.root.add_child(ng_xml.root)
      return xml.to_xml
  elsif xml.kind_of?(Nokogiri::XML::Node)
      xml.add_child(ng_xml.root)
      return xml.to_xml
  else
      raise "You can only pass instances of Nokogiri::XML::Node into this method.  You passed in #{xml}"
  end
end