You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Class: AWS::Core::Options::XMLSerializer
- Inherits:
-
Object
- Object
- AWS::Core::Options::XMLSerializer
show all
- Defined in:
- lib/aws/core/options/xml_serializer.rb
Overview
Given a hash of serialization rules, an XMLSerializer can convert
a hash of request options into XML. The request options are
validated before returning XML.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(namespace, operation_name, operation) ⇒ XMLSerializer
Returns a new instance of XMLSerializer
28
29
30
31
32
33
34
|
# File 'lib/aws/core/options/xml_serializer.rb', line 28
def initialize namespace, operation_name, operation
@namespace = namespace
@operation_name = operation_name
@rules = operation[:inputs]
@http = operation[:http]
@validator = Validator.new(rules)
end
|
Instance Attribute Details
#http ⇒ Hash?
46
47
48
|
# File 'lib/aws/core/options/xml_serializer.rb', line 46
def http
@http
end
|
#namespace ⇒ String
40
41
42
|
# File 'lib/aws/core/options/xml_serializer.rb', line 40
def namespace
@namespace
end
|
#operation_name ⇒ String
Returns the name of the API operation.
37
38
39
|
# File 'lib/aws/core/options/xml_serializer.rb', line 37
def operation_name
@operation_name
end
|
#rules ⇒ Hash
43
44
45
|
# File 'lib/aws/core/options/xml_serializer.rb', line 43
def rules
@rules
end
|
49
50
51
|
# File 'lib/aws/core/options/xml_serializer.rb', line 49
def validator
@validator
end
|
Instance Method Details
#serialize!(request_options) ⇒ String
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/aws/core/options/xml_serializer.rb', line 56
def serialize request_options
if http && http[:request_payload]
payload = http[:request_payload]
root_node_name = rules[payload][:name]
params = request_options[payload]
rules = self.rules[payload][:members]
else
root_node_name = "#{operation_name}Request"
params = request_options
rules = self.rules
end
xml = Nokogiri::XML::Builder.new
xml.send(root_node_name, :xmlns => namespace) do |xml|
hash_members_xml(params, rules, xml)
end
xml.doc.root.to_xml
end
|