Module: OM::XML::Container::ClassMethods

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

Overview

Class Methods – These methods will be available on classes that include this Module

Instance Method Summary collapse

Instance Method Details

#from_xml(xml = nil, tmpl = self.new) ⇒ Object

Careful! If you call this from a constructor, be sure to provide something ‘ie. self’ as the @tmpl. Otherwise, you will get an infinite loop!



12
13
14
15
16
17
18
19
20
21
# File 'lib/om/xml/container.rb', line 12

def from_xml(xml=nil, tmpl=self.new) # :nodoc:
  if xml.nil?
    tmpl.ng_xml = self.xml_template
  elsif xml.kind_of? Nokogiri::XML::Node
    tmpl.ng_xml = xml
  else
    tmpl.ng_xml = Nokogiri::XML::Document.parse(xml)
  end
  return tmpl
end

#xml_templateObject



23
24
25
# File 'lib/om/xml/container.rb', line 23

def xml_template
  Nokogiri::XML::Document.parse("")
end