Class: Libis::Services::Rosetta::ProducerAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/libis/services/rosetta/producer_agent.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_xml(xml) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/libis/services/rosetta/producer_agent.rb', line 42

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

Instance Method Details

#to_hashObject



26
27
28
# File 'lib/libis/services/rosetta/producer_agent.rb', line 26

def to_hash
  attributes.cleanup
end

#to_xmlObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/libis/services/rosetta/producer_agent.rb', line 30

def to_xml
  Libis::Tools::XmlDocument.build do |xml|
    # noinspection RubyResolve
    xml. {
      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(save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
end