Simple Cached Settings
Gem for storing global configuration settings in an ActiveRecord::Model.
Installation
Add this line to your application's Gemfile:
gem 'simple_cached_settings'
And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_cached_settings
Setup
Generate settings model and migration:
$ rails g simple_cached_settings <settings_name>
Apply migration:
$ rake db:migrate
Now you have the model that looks something like this:
class MySettings < SimpleCachedSettings::Settings
end
Usage
MySettings.write(:foo, 'bar')
MySettings.read(:foo)
=> 'bar'
It's possible to store settings values of four types: String, Integer, Float and Boolean
MySettings.write(:foo, 'bar')
MySettings.write(:number_of_chairs, 12)
MySettings.write(:gods_mode, true)
MySettings.write(:caliber, 7.62)
Contributing
- Fork it ( https://github.com/Le6ow5k1/simple_cached_settings/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request