Class: FreshBooks::XmlSerializer::ArraySerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/freshbooks/xml_serializer/serializers.rb

Class Method Summary collapse

Class Method Details

.to_node(member_name, value) ⇒ Object


79
80
81
82
83
84
85
# File 'lib/freshbooks/xml_serializer/serializers.rb', line 79

def self.to_node(member_name, value)
  element = REXML::Element.new(member_name)
  value.each { |array_elem|
    element.add_element(REXML::Document.new(array_elem.to_xml))
  }
  element
end

.to_value(xml_val) ⇒ Object


87
88
89
90
91
# File 'lib/freshbooks/xml_serializer/serializers.rb', line 87

def self.to_value(xml_val)
  xml_val.elements.map { |elem|
    FreshBooks::const_get(elem.name.camelize)::new_from_xml(elem) unless XmlSerializer.deprecated? elem
  }.compact
end