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



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

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

#at_xpath(a_path) ⇒ Object



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

def at_xpath a_path
  document.at_xpath a_path
end

#documentObject



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

def document
  xml = @xml.document.clone
  remove_unassigned_values_from xml
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

#remove_unspecified_valuesObject



62
63
64
# File 'lib/match_point/xml_instance.rb', line 62

def remove_unspecified_values

end

#success?Boolean

Returns:

  • (Boolean)


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

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