Given this terminology:
set_terminology do |t|
t.root(:path => "orcid-work")
t.work_title(:path => "work-title")
end
This does not work:
object.work_title = "test title"
This is because Nokogiri does not support this:
xml.work-title("test title")
Instead, it supports:
xml.send(:'work-title', 'test title')
OM is using eval to run a string as a line of code. That line of code is Nokogiri code. We need to convert the string as it is now to use sends. Nested sends might look like this:
b = Nokogiri::XML::Builder.new do |xml|
xml.send(:'foo-bar') {
xml.send(:'bar-foo', 'hello')
}
end
https://github.com/projecthydra/om/blob/v3.0.4/lib/om/xml/term_value_operators.rb#L170
The code that needs to change is around here:
class: lib/om/xml/term_value_operators.rb
method: insert_from_template(parent_node, new_values, template)
builder = Nokogiri::XML::Builder.with(parent_node) do |xml|
new_values.each do |builder_new_value|
builder_new_value = builder_new_value.gsub(/'/, "\\\\'") # escape any apostrophes in the new value
if matchdata = /xml\.@(\w+)/.match(template)
parent_node.set_attribute(matchdata[1], builder_new_value)
else
builder_arg = eval('"'+ template + '"') # this inserts builder_new_value into the builder template
eval(builder_arg)
end
end
end
return parent_node
end
One possible solution is that builder_arg needs to get converted to use sends.
Given this terminology:
This does not work:
object.work_title = "test title"
This is because Nokogiri does not support this:
Instead, it supports:
OM is using eval to run a string as a line of code. That line of code is Nokogiri code. We need to convert the string as it is now to use sends. Nested sends might look like this:
https://github.com/projecthydra/om/blob/v3.0.4/lib/om/xml/term_value_operators.rb#L170
The code that needs to change is around here:
class: lib/om/xml/term_value_operators.rb
method: insert_from_template(parent_node, new_values, template)
One possible solution is that builder_arg needs to get converted to use sends.