README.md in config_mapper-1.7.0 vs README.md in config_mapper-1.8.0
- old
+ new
@@ -1,9 +1,9 @@
# ConfigMapper
[![Gem Version](https://badge.fury.io/rb/config_mapper.svg)](https://badge.fury.io/rb/config_mapper)
-[![Build Status](https://travis-ci.org/mdub/config_mapper.svg?branch=master)](https://travis-ci.org/mdub/config_mapper)
+[![Build Status](https://github.com/mdub/config_mapper/actions/workflows/test.yaml/badge.svg?branch=master)](https://github.com/mdub/config_mapper/actions/workflows/test.yaml)
ConfigMapper maps configuration data onto Ruby objects.
<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
@@ -70,25 +70,10 @@
errors = ConfigMapper.configure_with(config_data, state)
state.orientation #=> "North"
state.position.x #=> 2
```
-It can even populate Hashes of objects, e.g.
-
-```ruby
-positions = Hash.new { |h,k| h[k] = Position.new }
-
-config_data = {
- "fred" => { "x" => 2, "y" => 4 },
- "mary" => { "x" => 3, "y" => 5 }
-}
-
-ConfigMapper.configure_with(config_data, positions)
-positions["fred"].x #=> 2
-positions["mary"].y #=> 5
-```
-
### Target object
Given
```ruby
@@ -132,11 +117,11 @@
provide a base-class, `ConfigMapper::ConfigStruct`, with a DSL that
makes it even easier to declare configuration data-structures.
### Attributes
-The `attribute` method is similar to `attr_accessor`, defining both reader and writer methods for the named attribute.
+The `attribute` method is similar to `attr_accessor`, defining both reader and writer methods for the named attribute.
```ruby
require "config_mapper/config_struct"
class State < ConfigMapper::ConfigStruct
@@ -202,11 +187,11 @@
Specify a default value of `nil` to mark an attribute as optional. Attributes without a default are treated as "required".
### Sub-components
-The `component` method defines a nested component object, itself a `ConfigStruct`.
+The `component` method defines a nested component object, itself a `ConfigStruct`.
```ruby
class State < ConfigMapper::ConfigStruct
component :position do
@@ -215,11 +200,11 @@
end
end
```
-`component_list` declares a nested list of configurable objects, indexed by position, and `component_dict` declares a dictionary (map) of configurable objects, indexed by an arbitrary key.
+`component_list` declares a nested list of configurable objects, indexed by position.
```ruby
class Polygon < ConfigMapper::ConfigStruct
component_list :points do
@@ -227,9 +212,14 @@
attribute :y
end
end
+```
+
+`component_dict` declares a dictionary (map) of configurable objects, indexed by an arbitrary key.
+
+```ruby
class Cargo < ConfigMapper::ConfigStruct
component_dict :packages do
attribute :contents
attribute :weight, Float