Module: FIRM::Serializable::XML::SerializeClassMethods

Included in:
ID, SerializeClassMethods
Defined in:
lib/firm/serializer/xml.rb

Overview

extend serialization class methods

Instance Method Summary collapse

Instance Method Details

#from_xml(xml) ⇒ Object



522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/firm/serializer/xml.rb', line 522

def from_xml(xml)
  data = XML::HashAdapter.new(xml)
  # deserializing alias
  if xml.has_attribute?('alias')
    Serializable::Aliasing.resolve_anchor(self, xml['alias'].to_i)
  else
    instance = self.allocate
    Serializable::Aliasing.restore_anchor(xml['anchor'].to_i, instance) if xml.has_attribute?('anchor')
    instance.__send__(:init_from_serialized, data)
            .__send__(:from_serialized, data)
            .__send__(:finalize_from_serialized)
  end
end