Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/remote/core_ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#build_internal_xml(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_record/remote/core_ext/hash.rb', line 26

def build_internal_xml(options = {})
  options[:builder] ||= Builder::XmlMarkup.new(indent: 0)
  builder = options[:builder]

  root = ActiveSupport::XmlMini.rename_key(options[:root].to_s, options)

  builder.tag!(root) do
    each { |key, value| ActiveSupport::XmlMini.to_tag(key, value, options) }
    yield builder if block_given?
  end
  builder.target!
end

#to_soap(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/active_record/remote/core_ext/hash.rb', line 3

def to_soap(options = {})
  require 'active_support/builder' unless defined?(Builder)

  options = options.dup
  options[:indent]       ||= 2
  options[:root]         ||= 'hash'
  options[:soap_builder] ||= Builder::XmlMarkup.new(indent: options[:indent])

  soap_builder = options[:soap_builder]

  soap_builder.Envelope xmlns: "http://schemas.xmlsoap.org/soap/envelope/" do

    soap_builder.Body do

      soap_builder.tag!(options[:operation], xmlns: options[:namespace]) do
        soap_builder.tag!(options[:base_element], "\n#{build_internal_xml(options)}")
      end

    end

  end
end