One of my ruby classes draws data from a rather large, local, XML file that will only change with a new deploy.
Is the best practice in this case to keep the document as a constant, like:
class Product
XML_DOC = Nokogiri::XML(open("#{Rails.root}/myxmlfile.xml"))
end
or to access the document through a class method, like:
class Product
self.xml_doc
Nokogiri::XML(open("#{Rails.root}/myxmlfile.xml"))
end
end
I think that the class method may be the way to go, since it will be easier to mock in tests, but what's considered the best-practice for keeping an in-memory file like this?