Class: AWS::Core::Options::XMLSerializer
- Inherits:
-
Object
- Object
- AWS::Core::Options::XMLSerializer
- 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
- #namespace ⇒ String readonly
-
#operation_name ⇒ String
readonly
Returns the name of the API operation.
- #rules ⇒ Hash readonly
- #validator ⇒ Validator readonly
Instance Method Summary collapse
-
#initialize(namespace, operation_name, rules) ⇒ XMLSerializer
constructor
A new instance of XMLSerializer.
- #serialize!(request_options) ⇒ String
Constructor Details
#initialize(namespace, operation_name, rules) ⇒ XMLSerializer
Returns a new instance of XMLSerializer.
28 29 30 31 32 33 |
# File 'lib/aws/core/options/xml_serializer.rb', line 28 def initialize namespace, operation_name, rules @namespace = namespace @operation_name = operation_name @rules = rules @validator = Validator.new(rules) end |
Instance Attribute Details
#namespace ⇒ String (readonly)
39 40 41 |
# File 'lib/aws/core/options/xml_serializer.rb', line 39 def namespace @namespace end |
#operation_name ⇒ String (readonly)
Returns the name of the API operation.
36 37 38 |
# File 'lib/aws/core/options/xml_serializer.rb', line 36 def operation_name @operation_name end |
#rules ⇒ Hash (readonly)
42 43 44 |
# File 'lib/aws/core/options/xml_serializer.rb', line 42 def rules @rules end |
#validator ⇒ Validator (readonly)
45 46 47 |
# File 'lib/aws/core/options/xml_serializer.rb', line 45 def validator @validator end |
Instance Method Details
#serialize!(request_options) ⇒ String
52 53 54 55 56 57 58 |
# File 'lib/aws/core/options/xml_serializer.rb', line 52 def serialize xml = Nokogiri::XML::Builder.new xml.send("#{operation_name}Request", :xmlns => namespace) do |xml| hash_members_xml(, rules, xml) end xml.doc.root.to_xml end |