Module: Azure::Storage::Queue::Serialization
- Includes:
- Common::Service::Serialization
- Defined in:
- lib/azure/storage/queue/serialization.rb
Class Method Summary collapse
- .message_to_xml(message_text, encode) ⇒ Object
- .queue_enumeration_results_from_xml(xml) ⇒ Object
- .queue_from_xml(xml) ⇒ Object
- .queue_message_from_xml(xml, decode) ⇒ Object
- .queue_messages_from_xml(xml, decode) ⇒ Object
Class Method Details
.message_to_xml(message_text, encode) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/azure/storage/queue/serialization.rb', line 66 def self.(, encode) if encode builder = Nokogiri::XML::Builder.new do |xml| xml.QueueMessage { xml.MessageText Base64.strict_encode64() } end else builder = Nokogiri::XML::Builder.new(encoding: "utf-8") do |xml| xml.QueueMessage { xml.MessageText .encode("utf-8") } end end builder.to_xml end |
.queue_enumeration_results_from_xml(xml) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/azure/storage/queue/serialization.rb', line 79 def self.queue_enumeration_results_from_xml(xml) xml = slopify(xml) expect_node("EnumerationResults", xml) results = enumeration_results_from_xml(xml, Azure::Storage::Common::Service::EnumerationResults.new) return results unless (xml > "Queues").any? && ((xml > "Queues") > "Queue").any? if xml.Queues.Queue.count == 0 results.push(queue_from_xml(xml.Queues.Queue)) else xml.Queues.Queue.each { |queue_node| results.push(queue_from_xml(queue_node)) } end results end |
.queue_from_xml(xml) ⇒ Object
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/azure/storage/queue/serialization.rb', line 98 def self.queue_from_xml(xml) xml = slopify(xml) expect_node("Queue", xml) queue = Queue.new queue.name = xml.Name.text if (xml > "Name").any? queue. = (xml.Metadata) if (xml > "Metadata").any? queue end |
.queue_message_from_xml(xml, decode) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/azure/storage/queue/serialization.rb', line 49 def self.(xml, decode) xml = slopify(xml) expect_node("QueueMessage", xml) Message.new do |msg| msg.id = xml.MessageId.text if (xml > "MessageId").any? msg.insertion_time = xml.InsertionTime.text if (xml > "InsertionTime").any? msg.expiration_time = xml.ExpirationTime.text if (xml > "ExpirationTime").any? msg.dequeue_count = xml.DequeueCount.text.to_i if (xml > "DequeueCount").any? msg. = xml.MessageText.text if (xml > "MessageText").any? msg.time_next_visible = xml.TimeNextVisible.text if (xml > "TimeNextVisible").any? msg.pop_receipt = xml.PopReceipt.text if (xml > "PopReceipt").any? msg. = Base64.decode64(msg.) if msg. && decode end end |
.queue_messages_from_xml(xml, decode) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/azure/storage/queue/serialization.rb', line 31 def self.(xml, decode) xml = slopify(xml) expect_node("QueueMessagesList", xml) results = [] return results unless (xml > "QueueMessage").any? if xml.QueueMessage.count == 0 results.push((xml.QueueMessage, decode)) else xml.QueueMessage.each { || results.push((, decode)) } end results end |