Description
ActiveRecord has a lot of support for tables of similar values. But what about those one time only values, like site settings? This is what ARSettings is intended for. One line to add settings to your ActiveRecord classes. Two to non-ActiveRecord classes. And you can have settings that are not defined on any class as well.
Tested on Ruby versions 1.8.6, 1.8.7, 1.9.2 Tested against ActiveRecord versions 2.3.3, 2.3.5, 2.3.8 and 3.0.1 If you would like me to test against a specific version not on here, let me know.
Usage
First you need to create a table to store your settings, this will probably go in a migration, though the only requirement is that the schema is correct (see example)
- Use the settings class to store settings (see example)
- Package settings together under a single namespace (see example)
- Add settings directly to your ActiveRecord class and its instances (see example)
- Add settings to any class you like (see example)
Installation
gem install arsettings
Dependencies
Bugs / Contribution
If you discover any errors / bugs, please inform me, and I will fix them and push out a new version.
If you wish to fix it yourself, fork it, fix it, and send me a pull request.
If you think it would fit your use better if it did this or if the interface would be a lot nicer given that then let me know so I can consider that and make the gem better.
License
Copyright (c) 2010 Joshua Cheek
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.