Constantizer
Constantizer helps you manage your ruby constants to be used through out your application.
Features
- Constants are added using YAML files.
Installation
Add this line to your application's Gemfile:
gem 'constantizer'
And then execute:
$ bundle
And then execute:
$ bundle exec constantizer install
Constants directory will be created:
└── config
└── constants
└── common.yml
Configurations
You can configure the gem to use a specific directory other than the default. To achive that, in constantizer.rb file add the following:
Constantizer.configure do |config|
config.directory = 'special_directory'
end
now put the YAML files contaning the constants under that special_directory
Usage
Constantizer allow you to create constants that are accessible from everywhere in your app.
Given the following YAML file
currencies:
- USD
- EUR
default_currency: USD
You can go to anywhere in your app and do the following:
CURRENCIES.include?('USD') #=> true
Contributing
- Fork it
- 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