dry-initializer 2.4.0 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.codeclimate.yml +10 -21
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
- data/.github/ISSUE_TEMPLATE/---bug-report.md +30 -0
- data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
- data/.github/workflows/custom_ci.yml +58 -0
- data/.github/workflows/docsite.yml +34 -0
- data/.github/workflows/sync_configs.yml +56 -0
- data/.gitignore +2 -0
- data/.rspec +1 -1
- data/.rubocop.yml +76 -25
- data/CHANGELOG.md +150 -14
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +29 -0
- data/Gemfile +25 -18
- data/Gemfile.devtools +16 -0
- data/Guardfile +3 -3
- data/LICENSE +20 -0
- data/README.md +17 -79
- data/Rakefile +4 -4
- data/benchmarks/compare_several_defaults.rb +27 -27
- data/benchmarks/plain_options.rb +14 -14
- data/benchmarks/plain_params.rb +22 -22
- data/benchmarks/with_coercion.rb +14 -14
- data/benchmarks/with_defaults.rb +17 -17
- data/benchmarks/with_defaults_and_coercion.rb +14 -14
- data/bin/.gitkeep +0 -0
- data/docsite/source/attributes.html.md +106 -0
- data/docsite/source/container-version.html.md +39 -0
- data/docsite/source/index.html.md +43 -0
- data/docsite/source/inheritance.html.md +43 -0
- data/docsite/source/optionals-and-defaults.html.md +130 -0
- data/docsite/source/options-tolerance.html.md +27 -0
- data/docsite/source/params-and-options.html.md +74 -0
- data/docsite/source/rails-support.html.md +101 -0
- data/docsite/source/readers.html.md +43 -0
- data/docsite/source/skip-undefined.html.md +59 -0
- data/docsite/source/type-constraints.html.md +160 -0
- data/dry-initializer.gemspec +13 -13
- data/lib/dry-initializer.rb +1 -1
- data/lib/dry/initializer.rb +17 -16
- data/lib/dry/initializer/builders.rb +2 -2
- data/lib/dry/initializer/builders/attribute.rb +16 -11
- data/lib/dry/initializer/builders/initializer.rb +9 -13
- data/lib/dry/initializer/builders/reader.rb +4 -2
- data/lib/dry/initializer/builders/signature.rb +3 -3
- data/lib/dry/initializer/config.rb +25 -12
- data/lib/dry/initializer/definition.rb +20 -71
- data/lib/dry/initializer/dispatchers.rb +101 -33
- data/lib/dry/initializer/dispatchers/build_nested_type.rb +59 -0
- data/lib/dry/initializer/dispatchers/check_type.rb +43 -0
- data/lib/dry/initializer/dispatchers/prepare_default.rb +40 -0
- data/lib/dry/initializer/dispatchers/prepare_ivar.rb +12 -0
- data/lib/dry/initializer/dispatchers/prepare_optional.rb +13 -0
- data/lib/dry/initializer/dispatchers/prepare_reader.rb +30 -0
- data/lib/dry/initializer/dispatchers/prepare_source.rb +28 -0
- data/lib/dry/initializer/dispatchers/prepare_target.rb +44 -0
- data/lib/dry/initializer/dispatchers/unwrap_type.rb +22 -0
- data/lib/dry/initializer/dispatchers/wrap_type.rb +28 -0
- data/lib/dry/initializer/mixin.rb +4 -4
- data/lib/dry/initializer/mixin/root.rb +1 -0
- data/lib/dry/initializer/struct.rb +39 -0
- data/lib/dry/initializer/undefined.rb +2 -0
- data/lib/dry/initializer/version.rb +5 -0
- data/lib/tasks/benchmark.rake +13 -13
- data/lib/tasks/profile.rake +16 -16
- data/project.yml +2 -0
- data/spec/attributes_spec.rb +7 -7
- data/spec/coercion_of_nil_spec.rb +25 -0
- data/spec/custom_dispatchers_spec.rb +6 -6
- data/spec/custom_initializer_spec.rb +2 -2
- data/spec/default_values_spec.rb +9 -9
- data/spec/definition_spec.rb +16 -12
- data/spec/invalid_default_spec.rb +2 -2
- data/spec/list_type_spec.rb +32 -0
- data/spec/missed_default_spec.rb +2 -2
- data/spec/nested_type_spec.rb +48 -0
- data/spec/optional_spec.rb +16 -16
- data/spec/options_tolerance_spec.rb +2 -2
- data/spec/public_attributes_utility_spec.rb +5 -5
- data/spec/reader_spec.rb +13 -13
- data/spec/repetitive_definitions_spec.rb +9 -9
- data/spec/several_assignments_spec.rb +9 -9
- data/spec/spec_helper.rb +6 -3
- data/spec/subclassing_spec.rb +5 -5
- data/spec/support/coverage.rb +7 -0
- data/spec/support/warnings.rb +7 -0
- data/spec/type_argument_spec.rb +15 -15
- data/spec/type_constraint_spec.rb +46 -28
- data/spec/value_coercion_via_dry_types_spec.rb +8 -8
- metadata +51 -34
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b6ced45dbc940dabce6d9f202a03e1ffc01b46cc14cb8981961d959392837a56
|
4
|
+
data.tar.gz: 70357b155bbe3516384a62d42b222f31ca401f29d8377dec06220124c0e95c07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c24c4d7127c8723d2142033da1a50f87450b725f69aa6948ea5b311154006e754f2ceaca88419e07bd4d648749097a9037763d180cfe87b8db525da888d82c2
|
7
|
+
data.tar.gz: 39dd6072626a6e80cc485c63462c19a93f1fa72c9e91300bb175c6c4ac643e71189963d8ee2d2f67dab4c1265dc224119ff3b3aa488f294231e333def76e9770
|
data/.codeclimate.yml
CHANGED
@@ -1,23 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# this file is managed by dry-rb/devtools project
|
2
|
+
|
3
|
+
version: "2"
|
4
|
+
|
5
|
+
exclude_patterns:
|
6
|
+
- "benchmarks/"
|
7
|
+
- "examples/"
|
8
|
+
- "spec/"
|
9
|
+
|
10
|
+
plugins:
|
3
11
|
rubocop:
|
4
12
|
enabled: true
|
5
|
-
checks:
|
6
|
-
Rubocop/Style/FrozenStringLiteralComment:
|
7
|
-
enabled: false
|
8
|
-
Rubocop/Style/PercentLiteralDelimiters:
|
9
|
-
enabled: false
|
10
|
-
Rubocop/Lint/UnderscorePrefixedVariableName:
|
11
|
-
enabled: false
|
12
|
-
duplication:
|
13
|
-
enabled: true
|
14
|
-
config:
|
15
|
-
languages:
|
16
|
-
- ruby
|
17
|
-
exclude_paths:
|
18
|
-
- "benchmarks/**/*"
|
19
|
-
- "spec/**/*"
|
20
|
-
- "lib/tasks/**/*"
|
21
|
-
ratings:
|
22
|
-
paths:
|
23
|
-
- "lib/**/*"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
name: "\U0001F41B Bug report"
|
3
|
+
about: See CONTRIBUTING.md for more information
|
4
|
+
title: ''
|
5
|
+
labels: bug
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Before you submit this: WE ONLY ACCEPT BUG REPORTS AND FEATURE REQUESTS**
|
11
|
+
|
12
|
+
For more information see `CONTRIBUTING.md`.
|
13
|
+
|
14
|
+
**Describe the bug**
|
15
|
+
|
16
|
+
A clear and concise description of what the bug is.
|
17
|
+
|
18
|
+
**To Reproduce**
|
19
|
+
|
20
|
+
Provide detailed steps to reproduce, an executable script would be best.
|
21
|
+
|
22
|
+
**Expected behavior**
|
23
|
+
|
24
|
+
A clear and concise description of what you expected to happen.
|
25
|
+
|
26
|
+
**Your environment**
|
27
|
+
|
28
|
+
- Affects my production application: **YES/NO**
|
29
|
+
- Ruby version: ...
|
30
|
+
- OS: ...
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
name: "\U0001F6E0 Feature request"
|
3
|
+
about: See CONTRIBUTING.md for more information
|
4
|
+
title: ''
|
5
|
+
labels: feature
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
Summary of what the feature is supposed to do.
|
11
|
+
|
12
|
+
## Examples
|
13
|
+
|
14
|
+
Code examples showing how the feature could be used.
|
15
|
+
|
16
|
+
## Resources
|
17
|
+
|
18
|
+
Additional information, like a link to the discussion forum thread where the feature was discussed etc.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
paths:
|
6
|
+
- .github/workflows/custom_ci.yml
|
7
|
+
- lib/**
|
8
|
+
- spec/**
|
9
|
+
- Rakefile
|
10
|
+
- Gemfile
|
11
|
+
- Gemfile.devtools
|
12
|
+
- "*.gemspec"
|
13
|
+
- ".rubocop.yml"
|
14
|
+
pull_request:
|
15
|
+
branches:
|
16
|
+
- master
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
tests:
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
strategy:
|
22
|
+
fail-fast: false
|
23
|
+
matrix:
|
24
|
+
ruby:
|
25
|
+
- "2.7"
|
26
|
+
- "2.6"
|
27
|
+
- "2.5"
|
28
|
+
- "2.4"
|
29
|
+
- "jruby"
|
30
|
+
runtime_deps:
|
31
|
+
- "dry-types-latest"
|
32
|
+
- "dry-types-master"
|
33
|
+
include:
|
34
|
+
- ruby: "2.6"
|
35
|
+
coverage: "true"
|
36
|
+
- runtime_deps: "dry-types-master"
|
37
|
+
dry_types_from_master: "true"
|
38
|
+
steps:
|
39
|
+
- uses: actions/checkout@v1
|
40
|
+
- name: Set up Ruby
|
41
|
+
uses: eregon/use-ruby-action@master
|
42
|
+
with:
|
43
|
+
ruby-version: ${{matrix.ruby}}
|
44
|
+
- name: Install latest bundler
|
45
|
+
run: |
|
46
|
+
gem install bundler
|
47
|
+
bundle config set without 'tools benchmarks docs'
|
48
|
+
- name: Bundle install
|
49
|
+
run: bundle install --jobs 4 --retry 3
|
50
|
+
env:
|
51
|
+
DRY_TYPES_FROM_MASTER: ${{matrix.dry_types_from_master}}
|
52
|
+
- name: Run all tests
|
53
|
+
env:
|
54
|
+
DRY_TYPES_FROM_MASTER: ${{matrix.dry_types_from_master}}
|
55
|
+
COVERAGE: ${{matrix.coverage}}
|
56
|
+
CODACY_RUN_LOCAL: true
|
57
|
+
CODACY_PROJECT_TOKEN: ${{secrets.CODACY_PROJECT_TOKEN}}
|
58
|
+
run: bundle exec rake
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# this file is managed by dry-rb/devtools project
|
2
|
+
|
3
|
+
name: docsite
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
paths:
|
8
|
+
- docsite/**
|
9
|
+
- .github/workflows/docsite.yml
|
10
|
+
branches:
|
11
|
+
- master
|
12
|
+
- release-**
|
13
|
+
tags:
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
update-docs:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v1
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: actions/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: "2.6.x"
|
24
|
+
- name: Install dependencies
|
25
|
+
run: |
|
26
|
+
gem install bundler
|
27
|
+
bundle install --jobs 4 --retry 3 --without benchmarks sql
|
28
|
+
- name: Symlink ossy
|
29
|
+
run: mkdir -p bin && ln -sf "$(bundle show ossy)/bin/ossy" bin/ossy
|
30
|
+
- name: Trigger dry-rb.org deploy
|
31
|
+
env:
|
32
|
+
GITHUB_LOGIN: dry-bot
|
33
|
+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
34
|
+
run: bin/ossy github workflow dry-rb/dry-rb.org ci
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# this file is managed by dry-rb/devtools project
|
2
|
+
|
3
|
+
name: sync_configs
|
4
|
+
|
5
|
+
on:
|
6
|
+
repository_dispatch:
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
sync-configs:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
if: github.event.action == 'sync_configs'
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v1
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: eregon/use-ruby-action@master
|
16
|
+
with:
|
17
|
+
ruby-version: 2.6
|
18
|
+
- name: Install latest bundler
|
19
|
+
run: |
|
20
|
+
gem install bundler
|
21
|
+
bundle config set without 'tools benchmarks docs'
|
22
|
+
- name: Install dependencies
|
23
|
+
run: bundle install --jobs 4 --retry 3 --without tools test benchmarks docs
|
24
|
+
- name: Symlink ossy
|
25
|
+
run: ln -sf "$(bundle info ossy --path)/bin/ossy" bin/ossy
|
26
|
+
- name: Clone devtools
|
27
|
+
run: git clone https://github.com/dry-rb/devtools.git tmp/devtools
|
28
|
+
- name: Compile file templates
|
29
|
+
env:
|
30
|
+
GITHUB_LOGIN: dry-bot
|
31
|
+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
32
|
+
run: |
|
33
|
+
if [ -f "project.yml" ]; then
|
34
|
+
for t in `ls tmp/devtools/templates`
|
35
|
+
do
|
36
|
+
bin/ossy t c tmp/devtools/templates/$t $(basename $t .erb) project.yml
|
37
|
+
done
|
38
|
+
fi
|
39
|
+
- name: Update configuration files from devtools
|
40
|
+
run: |
|
41
|
+
if [ -f ".github/workflows/custom_ci.yml" ]; then
|
42
|
+
rsync -arv --exclude '.github/workflows/ci.yml' tmp/devtools/shared/ . ;
|
43
|
+
else
|
44
|
+
rsync -arv tmp/devtools/shared/ . ;
|
45
|
+
fi
|
46
|
+
- name: Commit changes
|
47
|
+
run: |
|
48
|
+
rm bin/ossy
|
49
|
+
git config --local user.email "dry-bot@dry-rb.org"
|
50
|
+
git config --local user.name "dry-bot"
|
51
|
+
git add -A
|
52
|
+
git commit -m "[devtools] sync configs" || echo "nothing changed"
|
53
|
+
- name: Push changes
|
54
|
+
uses: ad-m/github-push-action@master
|
55
|
+
with:
|
56
|
+
github_token: ${{ secrets.GH_PAT }}
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,51 +1,102 @@
|
|
1
|
-
|
1
|
+
# this file is managed by dry-rb/devtools project
|
2
|
+
|
2
3
|
AllCops:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
|
6
|
+
Style/EachWithObject:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Style/StringLiterals:
|
10
|
+
Enabled: true
|
11
|
+
EnforcedStyle: single_quotes
|
9
12
|
|
10
|
-
|
13
|
+
Style/ParallelAssignment:
|
11
14
|
Enabled: false
|
12
15
|
|
13
|
-
Style/
|
16
|
+
Style/Alias:
|
17
|
+
Enabled: true
|
18
|
+
EnforcedStyle: prefer_alias_method
|
19
|
+
|
20
|
+
Style/LambdaCall:
|
14
21
|
Enabled: false
|
15
22
|
|
16
|
-
Style/
|
23
|
+
Style/StabbyLambdaParentheses:
|
17
24
|
Enabled: false
|
18
25
|
|
19
|
-
Style/
|
26
|
+
Style/FormatString:
|
20
27
|
Enabled: false
|
21
28
|
|
22
29
|
Style/Documentation:
|
23
30
|
Enabled: false
|
24
31
|
|
25
|
-
|
32
|
+
Layout/SpaceInLambdaLiteral:
|
26
33
|
Enabled: false
|
27
34
|
|
28
|
-
|
35
|
+
Layout/MultilineMethodCallIndentation:
|
36
|
+
Enabled: true
|
37
|
+
EnforcedStyle: indented
|
38
|
+
|
39
|
+
Metrics/LineLength:
|
40
|
+
Max: 100
|
41
|
+
|
42
|
+
Metrics/MethodLength:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Metrics/ClassLength:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Metrics/BlockLength:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Metrics/AbcSize:
|
52
|
+
Max: 20
|
53
|
+
|
54
|
+
Metrics/CyclomaticComplexity:
|
55
|
+
Enabled: true
|
56
|
+
Max: 10
|
57
|
+
|
58
|
+
Lint/BooleanSymbol:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
Style/AccessModifierDeclarations:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
Style/BlockDelimiters:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Layout/IndentFirstArrayElement:
|
68
|
+
EnforcedStyle: consistent
|
69
|
+
|
70
|
+
Style/ClassAndModuleChildren:
|
29
71
|
Exclude:
|
30
|
-
-
|
72
|
+
- "spec/**/*_spec.rb"
|
31
73
|
|
32
|
-
|
74
|
+
Lint/HandleExceptions:
|
33
75
|
Exclude:
|
34
|
-
- spec
|
76
|
+
- "spec/spec_helper.rb"
|
35
77
|
|
36
|
-
|
78
|
+
Naming/PredicateName:
|
37
79
|
Enabled: false
|
38
80
|
|
39
|
-
|
81
|
+
Naming/FileName:
|
40
82
|
Exclude:
|
41
|
-
-
|
83
|
+
- "lib/dry-*.rb"
|
42
84
|
|
43
|
-
Style/
|
85
|
+
Style/SymbolArray:
|
44
86
|
Exclude:
|
45
|
-
- spec
|
87
|
+
- "spec/**/*_spec.rb"
|
46
88
|
|
47
|
-
Style/
|
48
|
-
|
89
|
+
Style/ConditionalAssignment:
|
90
|
+
Enabled: false
|
49
91
|
|
50
|
-
|
51
|
-
|
92
|
+
Naming/MethodName:
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
Style/AsciiComments:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
Style/DateTime:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
Style/IfUnlessModifier:
|
102
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,135 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
+
## [3.0.3] [2020-01-08]
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Constrained member arrays work correctly now (see #33) (@bjeanes + @solnic)
|
13
|
+
|
14
|
+
## [3.0.2] [2019-11-07]
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- Warnings about keyword arguments (flash-gordon)
|
19
|
+
|
20
|
+
## [3.0.1] [2019-04-15]
|
21
|
+
|
22
|
+
### Fixed
|
23
|
+
|
24
|
+
- Usage of underscored names of `option`-s and `param`-s (nepalez)
|
25
|
+
|
26
|
+
You can use any sequence of underscores except for in nested types.
|
27
|
+
In nested types single underscores can be used to split alphanumeric
|
28
|
+
parts only.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
class Test
|
32
|
+
extend Dry::Initializer
|
33
|
+
|
34
|
+
# Proper usage
|
35
|
+
option :foo_bar do
|
36
|
+
option :__foo__, proc(&:to_s)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Improper usage
|
41
|
+
option :__foo__ do
|
42
|
+
# ...
|
43
|
+
end
|
44
|
+
|
45
|
+
option :foo__bar do
|
46
|
+
# ...
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
This restriction is necessary because we constantize option/param names
|
52
|
+
when defining nested structs.
|
53
|
+
|
54
|
+
## [3.0.0] [2019-04-14]
|
55
|
+
|
56
|
+
### Added
|
57
|
+
|
58
|
+
- Support of wrapped types/coercers (nepalez)
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
class Test
|
62
|
+
# Wrap type to the array
|
63
|
+
param :foo, [proc(&:to_s)]
|
64
|
+
end
|
65
|
+
|
66
|
+
# And the value will be wrapped as well
|
67
|
+
test = Test.new(42)
|
68
|
+
test.foo # => ["42"]
|
69
|
+
```
|
70
|
+
|
71
|
+
- It works with several layers of nesting (nepalez)
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
class Test
|
75
|
+
# Wrap type to the array
|
76
|
+
param :foo, [[proc(&:to_s)]]
|
77
|
+
end
|
78
|
+
|
79
|
+
# And the value will be wrapped as well
|
80
|
+
test = Test.new(42)
|
81
|
+
test.foo # => [["42"]]
|
82
|
+
```
|
83
|
+
|
84
|
+
- Support of nested types/coercers (nepalez)
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
class Test
|
88
|
+
param :foo do
|
89
|
+
option :bar do
|
90
|
+
option :baz, proc(&:to_s)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
test = Test.new(bar: { "baz" => 42 })
|
96
|
+
test.foo.bar.baz # => "42"
|
97
|
+
```
|
98
|
+
|
99
|
+
- Wrapped/nested combinations are supported as well (nepalez)
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
class Test
|
103
|
+
param :foo, [] do
|
104
|
+
option :bar, proc(&:to_s)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
test = Test.new(bar: 42)
|
109
|
+
test.foo.first.bar # => "42"
|
110
|
+
```
|
111
|
+
|
112
|
+
## [2.7.0] Unreleazed
|
113
|
+
|
114
|
+
### Fixed
|
115
|
+
|
116
|
+
- Roll back master to the state of [2.5.0].
|
117
|
+
|
118
|
+
Somehow distinction between `@default_null` and `@null` variables
|
119
|
+
in the `Dry::Initializer::Builders` broken the `rom` library.
|
120
|
+
|
121
|
+
The version [2.6.0] has been yanked on rubygems, so the master
|
122
|
+
was rolled back to the previous state until the reason for
|
123
|
+
the incompatibility become clear (bjeanes, nepalez)
|
124
|
+
|
125
|
+
## [2.6.0] [2018-09-09] (YANKED)
|
126
|
+
|
127
|
+
## [2.5.0] [2018-08-17]
|
128
|
+
|
129
|
+
### Fixed
|
130
|
+
|
131
|
+
- `nil` coercion (belousovAV)
|
132
|
+
|
133
|
+
When default value is `nil` instead of `Dry::Initializer::UNDEFINED`,
|
134
|
+
the coercion should be applied to any value, including `nil`, because
|
135
|
+
we cannot distinct "undefined" `nil` from the "assigned" `nil` value.
|
136
|
+
|
8
137
|
## [2.4.0] [2018-02-01]
|
9
138
|
|
10
139
|
### Added
|
@@ -31,7 +160,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
31
160
|
```ruby
|
32
161
|
class Location < String
|
33
162
|
attr_reader :parameter # refers back to its parameter
|
34
|
-
|
163
|
+
|
35
164
|
def initialize(name, parameter)
|
36
165
|
super(name)
|
37
166
|
@parameter = parameter
|
@@ -319,7 +448,7 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
319
448
|
|
320
449
|
### Added
|
321
450
|
- No-undefined configuration of the initializer (nepalez, flash-gordon)
|
322
|
-
|
451
|
+
|
323
452
|
You can either extend or include module `Dry::Initializer` with additional option
|
324
453
|
`[undefined: false]`. This time `nil` will be assigned instead of
|
325
454
|
`Dry::Initializer::UNDEFINED`. Readers becomes faster because there is no need
|
@@ -367,18 +496,20 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
367
496
|
### Added
|
368
497
|
- enhancement via `Dry::Initializer::Attribute.dispatchers` registry (nepalez)
|
369
498
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
499
|
+
```ruby
|
500
|
+
# Register dispatcher for `:string` option
|
501
|
+
Dry::Initializer::Attribute.dispatchers << ->(string: nil, **op) do
|
502
|
+
string ? op.merge(type: proc(&:to_s)) : op
|
503
|
+
end
|
374
504
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
505
|
+
# Now you can use the `:string` key for `param` and `option`
|
506
|
+
class User
|
507
|
+
extend Dry::Initializer
|
508
|
+
param :name, string: true
|
509
|
+
end
|
380
510
|
|
381
|
-
|
511
|
+
User.new(:Andy).name # => "Andy"
|
512
|
+
```
|
382
513
|
|
383
514
|
### Changed
|
384
515
|
- optimize assignments for performance (nepalez)
|
@@ -429,7 +560,7 @@ In this version the code has been rewritten for simplicity
|
|
429
560
|
|
430
561
|
### Internal
|
431
562
|
- Refactor the way [#initializer] method is (re)defined (nepalez)
|
432
|
-
|
563
|
+
|
433
564
|
When you extend class with `Dry::Initializer::Mixin`, the initializer is
|
434
565
|
defined not "inside" the class per se, but inside the included module. The
|
435
566
|
reference to that module is stored as class-level `__initializer_mixin__`.
|
@@ -757,4 +888,9 @@ First public release
|
|
757
888
|
[2.1.0]: https://github.com/dry-rb/dry-initializer/compare/v2.0.0...v2.1.0
|
758
889
|
[2.2.0]: https://github.com/dry-rb/dry-initializer/compare/v2.1.0...v2.2.0
|
759
890
|
[2.3.0]: https://github.com/dry-rb/dry-initializer/compare/v2.2.0...v2.3.0
|
760
|
-
[2.4.0]: https://github.com/dry-rb/dry-initializer/compare/v2.3.0...v2.4.0
|
891
|
+
[2.4.0]: https://github.com/dry-rb/dry-initializer/compare/v2.3.0...v2.4.0
|
892
|
+
[2.6.0]: https://github.com/dry-rb/dry-initializer/compare/v2.4.0...v2.5.0
|
893
|
+
[2.6.0]: https://github.com/dry-rb/dry-initializer/compare/v2.5.0...v2.6.0
|
894
|
+
[3.0.0]: https://github.com/dry-rb/dry-initializer/compare/v2.5.0...v3.0.0
|
895
|
+
[3.0.1]: https://github.com/dry-rb/dry-initializer/compare/v3.0.0...v3.0.1
|
896
|
+
[3.0.2]: https://github.com/dry-rb/dry-initializer/compare/v3.0.1...v3.0.2
|