braintree / curator

Model and repository framework
MIT License
350 stars 39 forks source link

Configure curator/mongo without a YAML config file? #27

Closed brandonweiss closed 9 years ago

brandonweiss commented 12 years ago

After poking around a bit it seems the way curator is currently written it's not possible to manually set up a connection, and you have to use a YAML file? Or at least I couldn't figure out how. Is that correct?

I've always thought configuring databases connections with YAML files is kind of gross. Plus it makes it rather difficult if you keep your database connection strings in environment variables. Thoughts?

pgr0ss commented 12 years ago

You are correct. The only way to currently configure is via a YAML file. We went with YAML since this is a common pattern with Rails and other ruby projects.

I'm open to alternate solutions if you are interested in contributing.

One simple solution is to ERB the YAML config files so you can use environment variables.

Another solution is to add a connection attribute to Curator::Mongo::Configuration. Then, you can update Curator::Mongo::DataStore to use that connection if present, or instantiate a new one from the YAML config file if not.