I’m developing a model which holds configuration settings for server options. The number and type of server options change, and I need some input on the pros/cons of two ways of doing it.
I’m doing this separate from the rails ActiveRecord database. All my database interactions are going to be manually with the file system.
First, having the model dynamically create attributes as needed for each server specified. (as long as this is possible… I’ve never done it before)
Second, creating a single Hash, which has Keys of the server options, and values of the server settings.
I think the second would be easier to implement, but I’m not sure if it is the right way to go? It seems to be cleaner to go with dynamic attributes.
Is there a rule of thumb to go with for this?
Made something for you.
Here is how it would work.
I haven’t written the way it interacts with the files yet so you’ll have to write a proper SettingsFileManager.
If anything it should give you a good base to get started. But I wrote it primarily as a test to see what I know about ruby. Since it uses some semi-tricky stuff.
Hosted it on github too with some tests.