match_point 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/match_point/version.rb +1 -1
- data/lib/match_point/xml_instance.rb +9 -4
- data/spec/match_point_spec.rb +6 -0
- metadata +1 -1
data/lib/match_point/version.rb
CHANGED
@@ -35,22 +35,27 @@ module MatchPoint
|
|
35
35
|
def synchronize_object_to_xml
|
36
36
|
nodes_in_template = @template.xpath("//#{SPEC_NODE}")
|
37
37
|
nodes_in_template.each do | node_in_template |
|
38
|
-
|
38
|
+
define_accessors_for node_in_template
|
39
39
|
@nodes_paths = @nodes_paths.merge ({ node_in_template.text.to_sym => node_in_template.path })
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def define_accessors_for node_in_template
|
44
44
|
attr_value = @xml.xpath(remove_spec_node_from(node_in_template.path)).text
|
45
45
|
self.class.add_attr_reader_for node_in_template, attr_value
|
46
|
+
self.class.add_attr_writer_for node_in_template
|
47
|
+
end
|
48
|
+
|
49
|
+
def remove_spec_node_from a_path
|
50
|
+
a_path.gsub("/#{SPEC_NODE}", "")
|
46
51
|
end
|
47
52
|
|
48
53
|
def self.add_attr_reader_for node_in_template, attr_value
|
49
54
|
define_method node_in_template.text.to_sym, lambda { attr_value }
|
50
55
|
end
|
51
56
|
|
52
|
-
def
|
53
|
-
|
57
|
+
def self.add_attr_writer_for node_in_template
|
58
|
+
define_method (node_in_template.text).concat('=').to_sym, lambda { | new_value | self.class.add_attr_reader_for node_in_template, new_value }
|
54
59
|
end
|
55
60
|
|
56
61
|
end
|
data/spec/match_point_spec.rb
CHANGED