Module: RubyXmlMapper
- Defined in:
- lib/ruby-xml-mapper.rb
Defined Under Namespace
Modules: RubyXmlMapperClassMethods Classes: Boolean, HashOfStringAndNumeric
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize_from_xml(node, load_source = true) ⇒ Object
Source loading is ugly.
Class Method Details
.included(model) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby-xml-mapper.rb', line 22 def self.included model model.extend RubyXmlMapper::RubyXmlMapperClassMethods model.class_inheritable_accessor :xml_name model.class_inheritable_accessor :source_dir_path model.class_inheritable_accessor :xml_self_mapping model.class_inheritable_accessor :xml_content_mapping model.class_inheritable_hash :xml_attr_mappings model.class_inheritable_hash :xml_child_mappings model.xml_attr_mappings = {} model.xml_child_mappings = {} end |
Instance Method Details
#initialize_from_xml(node, load_source = true) ⇒ Object
Source loading is ugly
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ruby-xml-mapper.rb', line 38 def initialize_from_xml node, load_source = true initialize_from_xml_attr_mapping(node) if xml_attr_mappings.length # TODO must not be a magic attribute if @source && load_source unless source_dir_path raise "source_dir_path not defined in #{self.class.inspect}" end initialize_from_xml(self.class.parse_xml_file(File.(@source, source_dir_path)), false) else initialize_from_xml_child_mapping(node) if xml_child_mappings.length initialize_from_xml_self_mapping(node) if xml_self_mapping initialize_from_xml_content_mapping(node) if xml_content_mapping end end |