Class: ActiveMessaging::Adapters::AmazonSqs::SQSResponse
- Inherits:
-
Object
- Object
- ActiveMessaging::Adapters::AmazonSqs::SQSResponse
- Defined in:
- lib/activemessaging/adapters/asqs.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#http_response ⇒ Object
Returns the value of attribute http_response.
Instance Method Summary collapse
- #each_node(xp) ⇒ Object
- #errors ⇒ Object
- #errors? ⇒ Boolean
- #get_text(xpath, default = '') ⇒ Object
-
#initialize(response) ⇒ SQSResponse
constructor
A new instance of SQSResponse.
- #message_type ⇒ Object
- #nodes(xp) ⇒ Object
Constructor Details
#initialize(response) ⇒ SQSResponse
Returns a new instance of SQSResponse.
317 318 319 320 321 322 |
# File 'lib/activemessaging/adapters/asqs.rb', line 317 def initialize response # puts "response.body = #{response.body}" @http_response = response @headers = response.to_hash() @doc = REXML::Document.new(response.body) end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
315 316 317 |
# File 'lib/activemessaging/adapters/asqs.rb', line 315 def doc @doc end |
#headers ⇒ Object
Returns the value of attribute headers.
315 316 317 |
# File 'lib/activemessaging/adapters/asqs.rb', line 315 def headers @headers end |
#http_response ⇒ Object
Returns the value of attribute http_response.
315 316 317 |
# File 'lib/activemessaging/adapters/asqs.rb', line 315 def http_response @http_response end |
Instance Method Details
#each_node(xp) ⇒ Object
352 353 354 |
# File 'lib/activemessaging/adapters/asqs.rb', line 352 def each_node(xp) REXML::XPath.each(doc.root, xp) {|n| yield n} end |
#errors ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/activemessaging/adapters/asqs.rb', line 332 def errors return "HTTP Error: #{http_response.code} : #{http_response.}" unless http_response.kind_of?(Net::HTTPSuccess) msg = nil each_node('//Error') { |n| msg ||= "" c = n.elements['Code'].text m = n.elements['Message'].text msg << ", " if msg != "" msg << "#{c} : #{m}" } return msg end |
#errors? ⇒ Boolean
328 329 330 |
# File 'lib/activemessaging/adapters/asqs.rb', line 328 def errors? (not http_response.kind_of?(Net::HTTPSuccess)) or ( == "ErrorResponse") end |
#get_text(xpath, default = '') ⇒ Object
347 348 349 350 |
# File 'lib/activemessaging/adapters/asqs.rb', line 347 def get_text(xpath,default='') e = REXML::XPath.first( doc, xpath) e.nil? ? default : e.text end |
#message_type ⇒ Object
324 325 326 |
# File 'lib/activemessaging/adapters/asqs.rb', line 324 def return doc ? doc.root.name : '' end |
#nodes(xp) ⇒ Object
356 357 358 |
# File 'lib/activemessaging/adapters/asqs.rb', line 356 def nodes(xp) doc.elements.to_a(xp) end |