README.md in qonfig-0.8.0 vs README.md in qonfig-0.9.0

- old
+ new

@@ -19,11 +19,11 @@ require 'qonfig' ``` ## Usage -- [Definition and Access](#definition-and-access) +- [Definition and Settings Access](#definition-and-access) - [Configuration](#configuration) - [Inheritance](#inheritance) - [Composition](#composition) - [Hash representation](#hash-representation) - [Config reloading](#config-reloading) (reload config definitions and option values) @@ -41,10 +41,11 @@ --- ### Definition and Access ```ruby +# --- definition --- class Config < Qonfig::DataSet # nil by default setting :project_id # nested setting @@ -58,12 +59,14 @@ setting :vendor_api do setting :user, 'test_user' end end -config = Config.new +config = Config.new # your configuration object instance +# --- setting access --- + # get option value via method config.settings.project_id # => nil config.settings.vendor_api.host # => 'app.service.com' config.settings.vendor_api.user # => 'test_user' config.settings.enable_graphql # => false @@ -87,9 +90,15 @@ config[:enable_graphql] # => false # get option value in Hash#dig manner (and fail when the required key does not exist) config.dig(:vendor_api, :host) # => 'app.service.com' # (key exists) config.dig(:vendor_api, :port) # => Qonfig::UnknownSettingError # (key does not exist) + +# get a hash slice of setting options (and fail when the required key does not exist) +config.slice(:vendor_api) # => { 'vendor_api' => { 'host' => 'app_service', 'user' => 'test_user' } } +config.slice(:vendor_api, :user) # => { 'user' => 'test_user' } +config.slice(:project_api) # => Qonfig::UnknownSettingError # (key does not exist) +config.slice(:vendor_api, :port) # => Qonfig::UnknownSettingError # (key does not exist) ``` --- ### Configuration