README.md in anyway_config-1.1.2 vs README.md in anyway_config-1.1.3

- old
+ new

@@ -10,10 +10,12 @@ - [Influxer](https://github.com/palkan/influxer) - [AnyCable](https://github.com/anycable/anycable) +- [Sniffer](https://github.com/aderyabin/sniffer) + - [and others](https://github.com/palkan/anyway_config/network/dependents). ## Installation 1) Adding to a gem: @@ -85,10 +87,27 @@ attr_config user: 'root', password: 'root', host: 'localhost', options: {} end end ``` +#### Provide explicit values + +Sometimes it's useful to set some parameters explicitly during config initialization. +You can do that using `overrides` option: + +```ruby +config = MyCoolGem::Config.new( + overrides: { + user: 'john', + password: 'rubyisnotdead' + } +) + +# The value would not be overriden from other sources (such as YML file, env) +config.user == 'john' +``` + ### Dynamic configuration You can also create configuration objects without pre-defined schema (just like `Rails.application.config_for` but more [powerful](#railsapplicationconfig_for-vs-anywayconfigfor)): ```ruby @@ -116,9 +135,10 @@ ### Config clear and reload There are `#clear` and `#reload` functions on your config (which do exactly what they state). +Note: `#reload` also accepts `overrides` key to provide explicit values (see above). ## `Rails.application.config_for` vs `Anyway::Config.for` Rails 4.2 introduced new feature: `Rails.application.config_for`. It looks very similar to `Anyway::Config.for`, but there are some differences: