module XML::Mapping::ClassMethods
Public Instance Methods
load_from_xml(xml, options={:mapping=>:_default})
click to toggle source
Base on original method
# File lib/support/xml_mapping.rb, line 17 def load_from_xml(xml, options={:mapping=>:_default}) raise(MappingError, "undefined mapping: #{options[:mapping].inspect}") \ unless xml_mapping_nodes_hash.has_key?(options[:mapping]) || (superclass && superclass.xml_mapping_nodes_hash.has_key?(options[:mapping])) # create the new object. It is recommended that the class # have a no-argument initializer, so try new first. If that # doesn't work, try allocate, which bypasses the initializer. begin obj = self.new rescue ArgumentError # TODO: this may hide real errors. # how to statically check whether # self self.new accepts an empty # argument list? obj = self.allocate end obj.initialize_xml_mapping :mapping=>options[:mapping] obj.fill_from_xml xml, :mapping=>options[:mapping] obj end