polyrex-createobject 0.1.2 → 0.1.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/polyrex-createobject.rb +7 -2
- metadata +1 -1
data/lib/polyrex-createobject.rb
CHANGED
@@ -55,10 +55,15 @@ end
|
|
55
55
|
def create_node(parent_node, child_schema, params)
|
56
56
|
raise "create_node error: can't create record" unless valid_creation?
|
57
57
|
record = Document.new PolyrexSchema.new(child_schema).to_s
|
58
|
-
@id = (@id.to_i + 1).to_s
|
59
58
|
|
60
|
-
record.root.add_attribute('id', @id)
|
61
59
|
|
60
|
+
record.root.add_attribute('id', @id)
|
61
|
+
if @id[/[0-9]/] then
|
62
|
+
@id = (@id.to_i + 1).to_s
|
63
|
+
else
|
64
|
+
@id = XPath.first(@parent_node,root, 'count(//@id)').to_i + 1
|
65
|
+
end
|
66
|
+
|
62
67
|
a = child_schema[/[^\[]+(?=\])/].split(',')
|
63
68
|
a.each do |field_name|
|
64
69
|
field = XPath.first(record.root, 'summary/' + field_name)
|