class Reactor::Cm::XmlResponse

Attributes

xml[R]
xml_str[R]

Public Class Methods

new(xml) click to toggle source
# File lib/reactor/cm/xml_response.rb, line 14
def initialize(xml)
  @xml_str = xml
  @xml = REXML::Document.new(xml)
  @handler = Reactor::ResponseHandler::XmlAttribute.new
  @xpath = Reactor::XPathExtractor.new(@xml)
end

Public Instance Methods

ok?() click to toggle source
# File lib/reactor/cm/xml_response.rb, line 25
def ok?
  xp = xpath('//cm-code')

  if xp.is_a?(Array)
    codes = xp.map { |result| result.attribute('numeric').value }.uniq

    return codes.size == 1 && codes.first == '200'
  end

  xp.attribute('numeric').value == '200'
end
xpath(expr) click to toggle source
# File lib/reactor/cm/xml_response.rb, line 21
def xpath(expr)
  @xpath.match(expr)
end