Class: ActiveMessaging::Adapters::Sqs::SQSResponse
- Inherits:
-
Object
- Object
- ActiveMessaging::Adapters::Sqs::SQSResponse
- Defined in:
- lib/activemessaging/adapters/sqs.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.
364 365 366 367 368 369 |
# File 'lib/activemessaging/adapters/sqs.rb', line 364 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.
362 363 364 |
# File 'lib/activemessaging/adapters/sqs.rb', line 362 def doc @doc end |
#headers ⇒ Object
Returns the value of attribute headers.
362 363 364 |
# File 'lib/activemessaging/adapters/sqs.rb', line 362 def headers @headers end |
#http_response ⇒ Object
Returns the value of attribute http_response.
362 363 364 |
# File 'lib/activemessaging/adapters/sqs.rb', line 362 def http_response @http_response end |
Instance Method Details
#each_node(xp) ⇒ Object
399 400 401 |
# File 'lib/activemessaging/adapters/sqs.rb', line 399 def each_node(xp) REXML::XPath.each(doc.root, xp) {|n| yield n} end |
#errors ⇒ Object
379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/activemessaging/adapters/sqs.rb', line 379 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
375 376 377 |
# File 'lib/activemessaging/adapters/sqs.rb', line 375 def errors? (not http_response.kind_of?(Net::HTTPSuccess)) or ( == 'ErrorResponse') end |
#get_text(xpath, default = '') ⇒ Object
394 395 396 397 |
# File 'lib/activemessaging/adapters/sqs.rb', line 394 def get_text(xpath,default='') e = REXML::XPath.first( doc, xpath) e.nil? ? default : e.text end |
#message_type ⇒ Object
371 372 373 |
# File 'lib/activemessaging/adapters/sqs.rb', line 371 def return doc ? doc.root.name : '' end |
#nodes(xp) ⇒ Object
403 404 405 |
# File 'lib/activemessaging/adapters/sqs.rb', line 403 def nodes(xp) doc.elements.to_a(xp) end |