Class: Arbetsformedlingen::SOAPBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/arbetsformedlingen/soap_builder.rb

Overview

SOAP Envelope XML builder

Constant Summary collapse

SOAP_ATTRIBUTES =

SOAP attributes

{
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
  'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
  'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope',
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ SOAPBuilder

Initialize object

Yields:

  • (_self)

Yield Parameters:



22
23
24
25
26
27
# File 'lib/arbetsformedlingen/soap_builder.rb', line 22

def initialize
  @builder = Builder::XmlMarkup.new(indent: 2)
  @builder.instruct!

  yield self if block_given?
end

Class Method Details

.wrap(&block) ⇒ Object

Wrap block

See Also:



17
18
19
# File 'lib/arbetsformedlingen/soap_builder.rb', line 17

def self.wrap(&block)
  new.wrap(&block)
end

Instance Method Details

#to_xmlObject



39
40
41
# File 'lib/arbetsformedlingen/soap_builder.rb', line 39

def to_xml
  @builder.target!
end

#wrapSOAPBuilder

Wrap block in SOAP envelope

Returns:



31
32
33
34
35
36
37
# File 'lib/arbetsformedlingen/soap_builder.rb', line 31

def wrap
  @builder.soap12(:Envelope, SOAP_ATTRIBUTES) do |envelope|
    envelope.soap12(:Body) { |body| yield(body) }
  end

  self
end