As a Ruby library author, you can benefit from using Anyway Config by providing a better UX for your end-users:
- Zero-code configuration: no more boilerplate initializers.
- Per-environment and local settings support out-of-the-box.
For application developers, Anyway Config could be useful to:
- Keep configuration organized and use named configs instead of bloated
.env
/settings.yml
/whatever. - Free code of ENV/credentials/secrets dependency and use configuration classes instead—your code should not rely on configuration data sources.
Main concepts
Anyway Config abstractizes the configuration layer by introducing configuration classes which describe available parameters and their defaults. For example:
module Influxer
class Config < Anyway::Config
attr_config(
host: "localhost",
username: "root",
password: "root"
)
end
end
Using Ruby classes to represent configuration allows you to add helper methods and computed parameters easily, and makes the configuration testable.
The anyway_config
gem takes care of loading parameters from different sources (YAML, credentials/secrets, environment variables, etc.). Internally, we use a pipeline pattern and provide the Loaders API to manage and extend its functionality.