class Reactor::ResponseHandler::XmlAttribute

Public Instance Methods

get(response, attribute) click to toggle source
Calls superclass method Reactor::ResponseHandler::Base#get
# File lib/reactor/tools/response_handler/xml_attribute.rb, line 9
def get(response, attribute)
  super(response, attribute)

  name = attribute.name
  type = attribute.type

  method_name = "extract_#{type}"

  self.send(method_name, name)
end

Private Instance Methods

extract_list(name) click to toggle source

Extracts a list value with the given name and returns an array of strings.

# File lib/reactor/tools/response_handler/xml_attribute.rb, line 28
def extract_list(name)
  result = self.response.xpath("//#{name}/listitem/text()")
  result = result.kind_of?(Array) ? result : [result]

  result.map(&:to_s)
end
extract_signaturelist(name) click to toggle source

This shit will break with the slightest change of the CM.

# File lib/reactor/tools/response_handler/xml_attribute.rb, line 36
def extract_signaturelist(name)
  signatures = []
  self.response.xpath("//#{name}/").each do |potential_signature|
    if (potential_signature.name.to_s == "listitem")
      attribute = potential_signature.children.first.text.to_s
      group = potential_signature.children.last.text.to_s
      signatures << {:attribute => attribute, :group => group}
    end
  end
  signatures
end
extract_string(name) click to toggle source

Extracts a string value with the given name and returns a string.

# File lib/reactor/tools/response_handler/xml_attribute.rb, line 23
def extract_string(name)
  self.response.xpath("//#{name}/text()").to_s
end