README.md in qonfig-0.2.0 vs README.md in qonfig-0.3.0

- old
+ new

@@ -24,13 +24,13 @@ - [Definition and Access](#definition-and-access) - [Configuration](#configuration) - [Inheritance](#inheritance) - [Composition](#composition) - [Hash representation](#hash-representation) -- [State freeze](#state-freeze) - [Config reloading](#config-reloading) (reload config definitions and option values) - [Clear options](#clear-options) (set to nil) +- [State freeze](#state-freeze) - [Settings as Predicates](#settings-as-predicates) - [Load from YAML file](#load-from-yaml-file) - [Load from ENV](#load-from-env) - [Load from \_\_END\_\_](#load-from-__end__) (aka `load_from_self`) - [Smart Mixin](#smart-mixin) (`Qonfig::Configurable`) @@ -129,10 +129,27 @@ config = Config.new do |conf| conf.enable_middlewares = false conf.geo_api.provider = :amazon_maps conf.testing.engine = :crypto_test end + +# using a hash +config = Config.new( + testing: { engine: :mini_test, parallel: false }, + geo_api: { provider: :rambler_maps }, + enable_middlewares: true +) +config.configure(enable_middlewares: false) + +# using both hash and proc (proc has higher priority) +config = Config.new(enable_middlewares: true) do |conf| + conf.testing.parallel = true +end + +config.configure(geo_api: { provider: nil }) do |conf| + conf.testing.engine = :rspec +end ``` --- ### Inheritance @@ -270,15 +287,15 @@ config.settings.db.adapter # => 'mongoid' config.settings.logger # => #<Logger:0x00007ff9> (reloaded from defaults) config.settings.enable_api # => false (new setting) # reload with instant configuration -config.reload! do |conf| +config.reload!(db: { adapter: 'oracle' }) do |conf| conf.enable_api = true # changed instantly end -config.settings.db.adapter # => 'mongoid' +config.settings.db.adapter # => 'oracle' config.settings.logger = # => #<Logger:0x00007ff9> config.settings.enable_api # => true # value from instant change ``` --- @@ -335,10 +352,11 @@ config.settings.logger = Logger.new(StringIO.new) # => Qonfig::FrozenSettingsError config.settings.worker = :que # => Qonfig::FrozenSettingsError config.settings.db.adapter = 'mongoid' # => Qonfig::FrozenSettingsError config.reload! # => Qonfig::FrozenSettingsError +config.clear! # => Qonfig::FrozenSettingsError ``` --- ### Settings as Predicates @@ -439,22 +457,22 @@ ```ruby # --- strict mode --- class Config < Qonfig::DataSet setting :nonexistent_yaml do - load_from_yaml 'unexistent_file.yml', strict: true # true by default + load_from_yaml 'nonexistent_yaml.yml', strict: true # true by default end setting :another_key end Config.new # => Qonfig::FileNotFoundError # --- non-strict mode --- class Config < Qonfig::DataSet settings :nonexistent_yaml do - load_from_yaml 'unexistent_file.yml', strict: false + load_from_yaml 'nonexistent_yaml.yml', strict: false end setting :another_key end @@ -537,10 +555,10 @@ ```ruby class Config < Qonfig::DataSet load_from_self # on the root - setting :clowd do + setting :nested do load_from_self # nested end end config = Config.new