Module: OM::XML::Container

Extended by:
ActiveSupport::Concern
Defined in:
lib/om/xml/container.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ng_xmlObject

Returns the value of attribute ng_xml



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

def ng_xml
  @ng_xml
end

Instance Method Details

#to_xml(xml = ng_xml) ⇒ Object

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



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/om/xml/container.rb', line 40

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