Class: MoneyS3::Builders::MessageType

Inherits:
Object
  • Object
show all
Includes:
ParserCore::BaseBuilder
Defined in:
lib/money_s3/builders/message_type.rb

Instance Method Summary collapse

Instance Method Details

#builderObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/money_s3/builders/message_type.rb', line 6

def builder
  root = Ox::Element.new(name)
  root = add_attributes_and_namespaces(root)

  root << build_element('Status', data[:status], data[:status_attributes]) if data.key? :status
  if data.key? :reference
    element = Ox::Element.new('Reference')
    data[:reference].map { |i| Ox::Element.new('ID') << i }.each { |i| element << i }
    root << element
  end
  if data.key? :error_info
    data[:error_info].each { |i| root << ErrorInfoType.new('ErrorInfo', i).builder }
  end
  root << build_element('Data', data[:data], data[:data_attributes]) if data.key? :data

  root
end