Class: MatchPoint::XmlInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/match_point/xml_instance.rb

Constant Summary collapse

SPEC_NODE =
"MatchPointSpec"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(template, data) ⇒ Object



13
14
15
16
17
# File 'lib/match_point/xml_instance.rb', line 13

def self.from_hash template, data
  instance = self.new template
  instance.assign_values data
  instance
end

.from_xml(template, xml, error_node) ⇒ Object



6
7
8
9
10
11
# File 'lib/match_point/xml_instance.rb', line 6

def self.from_xml template, xml, error_node
  instance = self.new template
  instance.xml= xml
  instance.error_node = error_node
  instance
end

Instance Method Details

#assign_values(data) ⇒ Object



51
52
53
54
55
# File 'lib/match_point/xml_instance.rb', line 51

def assign_values data
  data.each do |key, value|
    assign_value value, node_path(key)
  end
end

#at_xpath(a_path) ⇒ Object



47
48
49
# File 'lib/match_point/xml_instance.rb', line 47

def at_xpath a_path
  @xml.at_xpath a_path
end

#documentObject



43
44
45
# File 'lib/match_point/xml_instance.rb', line 43

def document
  @xml.document.clone
end

#error_node=(error_node) ⇒ Object



19
20
21
# File 'lib/match_point/xml_instance.rb', line 19

def error_node= error_node
  @error_node = error_node
end

#operation_nameObject



35
36
37
# File 'lib/match_point/xml_instance.rb', line 35

def operation_name
  @operation_name
end

#operation_name=(a_name) ⇒ Object



39
40
41
# File 'lib/match_point/xml_instance.rb', line 39

def operation_name= a_name
  @operation_name = a_name
end

#success?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/match_point/xml_instance.rb', line 57

def success?
  !@xml.at_xpath(@error_node[:path]).has_attribute?(@error_node[:attribute])
end

#to_sObject



31
32
33
# File 'lib/match_point/xml_instance.rb', line 31

def to_s
  @xml.to_s
end

#to_xmlObject



27
28
29
# File 'lib/match_point/xml_instance.rb', line 27

def to_xml
  @xml.to_xml
end

#xml=(an_xml) ⇒ Object



23
24
25
# File 'lib/match_point/xml_instance.rb', line 23

def xml= an_xml
  @xml = Nokogiri::XML(an_xml)
end