Hi,
I do not have problem as such but I am quite new to Ruby. I have the following 3 repeatable bits of code in one method and I would like to know how a true Rubyist would first of all remove the duplication and secondly make it more reusable.
Here is the code in question:
file = File.new( destination)
doc = REXML::Document.new file
doc.elements.each("configuration/continuity2/plans") do |element|
element.attributes["storebasedir"] = "#{TEST_OUTPUT_DIRECTORY}"
end
doc.elements.each("configuration/add").each do |database|
database.raw_attributes = database.attributes.merge("connectionstring" => "#{TEST_CONNECTION_STRING}")
end
doc.elements.each("configuration/connectionStrings/plans") do |connectionString|
connectionString.raw_attributes = connectionString.attributes.merge("connectionString" => "#{TEST_CONNECTION_STRING}")
end
Any advice appreciated.
Cheers
Paul