class Libis::Services::Rosetta::Producer

Public Class Methods

from_xml(xml) click to toggle source
# File lib/libis/services/rosetta/producer.rb, line 58
def self.from_xml(xml)
  xml_doc = Libis::Tools::XmlDocument.parse(xml)
  hash = xml_doc.to_hash(
      strip_namespaces: true,
      delete_namespace_attributes: true,
      empty_tag_value: nil,
      convert_tags_to: lambda(&:to_sym)
  )
  # noinspection RubyArgCount
  self.new(hash[:producer_info])
end

Public Instance Methods

to_hash() click to toggle source
# File lib/libis/services/rosetta/producer.rb, line 42
def to_hash
  attributes.cleanup
end
to_xml() click to toggle source
# File lib/libis/services/rosetta/producer.rb, line 46
def to_xml
  Libis::Tools::XmlDocument.build do |xml|
    # noinspection RubyResolve
    xml.producer_info {
      xml.parent.default_namespace = 'http://www.exlibrisgroup.com/xsd/dps/backoffice/service'
      self.attributes.each do |name, value|
        xml.send(name, xmlns: '').text(value) if value
      end
    }
  end.to_xml
end