README.md in anyway_config-2.4.0 vs README.md in anyway_config-2.4.1
- old
+ new
@@ -542,10 +542,12 @@
```
You can also specify the `--app` option to put the newly created class into `app/configs` folder.
Alternatively, you can call `rails g anyway:app_config name param1 param2 ...`.
+**NOTE:** The generated `ApplicationConfig` class uses a singleton pattern along with `delegate_missing_to` to re-use the same instance across the application. However, the delegation can lead to unexpected behaviour and break Anyway Config internals if you have attributes named as `Anyway::Config` class methods. See [#120](https://github.com/palkan/anyway_config/issues/120).
+
## Using with Ruby
The default data loading mechanism for non-Rails applications is the following (ordered by priority from low to high):
1) **YAML configuration files**: `./config/<config-name>.yml`.
@@ -788,10 +790,22 @@
```sh
ejson decrypt config/secrets.ejson
```
+You can customize the JSON namespace under which a loader searches for configuration via `loader_options`:
+
+```ruby
+class MyConfig < Anyway::Config
+ # To look under the key "foo" instead of the default key of "my"
+ loader_options ejson_namespace: "foo"
+
+ # Or to disable namespacing entirely, and instead search in the root object
+ loader_options ejson_namespace: false
+end
+```
+
### Custom loaders
You can provide your own data loaders or change the existing ones using the Loaders API (which is very similar to Rack middleware builder):
```ruby
@@ -808,10 +822,11 @@
```ruby
def call(
name:, # config name
env_prefix:, # prefix for env vars if any
config_path:, # path to YML config
- local: # true|false, whether to load local configuration
+ local:, # true|false, whether to load local configuration
+ **options # custom options can be passed via Anyway::Config.loader_options example: "custom", option: "blah"
)
#=> must return Hash with configuration data
end
```