dry-initializer 1.3.0 → 1.4.0
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/dry-initializer.gemspec +1 -1
- data/lib/dry/initializer/attribute.rb +5 -1
- data/lib/dry/initializer/builder.rb +1 -1
- data/lib/dry/initializer/option.rb +0 -5
- data/lib/dry/initializer/param.rb +0 -2
- data/spec/options_var_spec.rb +10 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e6ae766c1972fc5888ab780a91efb1e819b328a
|
4
|
+
data.tar.gz: 6810b441c5758b0fee5efadda4616b2b67d8c6d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e3e5809a583a299986ed3624d5baa905816bd518d20bb0a5870a9efdda9ddf41388c239a9d5aab6e1027adfbe1abacaa643d2075e1f202d3f1a0b20f5b305d6
|
7
|
+
data.tar.gz: f6f9c2dd66ed22efc7e53677256b884082dc86a3fac923dd35dc7fbd480252ce8f0f800665d9e49520c803cd541c44120832ec888f63e0203866f90faef4dd1d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## v1.4.0 2017-03-08
|
2
|
+
|
3
|
+
### Changed (backward-incompatible)
|
4
|
+
- The `@__options__` hash now collects all assigned attributes,
|
5
|
+
collected via `#option` (as before), and `#param` (nepalez)
|
6
|
+
|
7
|
+
[Compare v1.3.0...v1.4.0](https://github.com/dry-rb/dry-initializer/compare/v1.3.0...v1.4.0)
|
8
|
+
|
1
9
|
## v1.3.0 2017-03-05
|
2
10
|
|
3
11
|
### Added
|
data/dry-initializer.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "dry-initializer"
|
3
|
-
gem.version = "1.
|
3
|
+
gem.version = "1.4.0"
|
4
4
|
gem.author = ["Vladimir Kochnev (marshall-lee)", "Andrew Kozin (nepalez)"]
|
5
5
|
gem.email = ["hashtable@yandex.ru", "andrew.kozin@gmail.com"]
|
6
6
|
gem.homepage = "https://github.com/dryrb/dry-initializer"
|
@@ -54,7 +54,11 @@ module Dry::Initializer
|
|
54
54
|
source == other.source
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
def postsetter
|
58
|
+
"@__options__[:#{target}] = @#{target}" \
|
59
|
+
" unless @#{target} == #{undefined}"
|
60
|
+
end
|
61
|
+
|
58
62
|
def getter
|
59
63
|
return unless reader
|
60
64
|
command = %w(private protected).include?(reader.to_s) ? reader : :public
|
data/spec/options_var_spec.rb
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
describe "@__options__" do
|
2
|
-
context "when class has
|
2
|
+
context "when class has params" do
|
3
3
|
before do
|
4
4
|
class Test::Foo
|
5
|
-
extend Dry::Initializer
|
6
|
-
param :foo
|
5
|
+
extend Dry::Initializer
|
6
|
+
param :foo, proc(&:to_s)
|
7
|
+
param :bar, default: proc { 1 }
|
8
|
+
param :baz, optional: true
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
10
|
-
it "
|
11
|
-
subject = Test::Foo.new(
|
12
|
+
it "collects coerced params with default values" do
|
13
|
+
subject = Test::Foo.new(:FOO)
|
12
14
|
|
13
|
-
expect(subject.instance_variable_get(:@__options__))
|
15
|
+
expect(subject.instance_variable_get(:@__options__))
|
16
|
+
.to eq({ foo: "FOO", bar: 1 })
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
context "when class has options" do
|
18
21
|
before do
|
19
22
|
class Test::Foo
|
20
|
-
extend Dry::Initializer
|
23
|
+
extend Dry::Initializer
|
21
24
|
option :foo
|
22
25
|
option :bar, default: proc { 1 }
|
23
26
|
option :baz, optional: true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-initializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Kochnev (marshall-lee)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|