dry-initializer 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a64c90248831e6513871de4f8f489422f3522e0
4
- data.tar.gz: bc6cfa16dd5a4922c54869d993fc3d8ac6e08bb6
3
+ metadata.gz: 7e6ae766c1972fc5888ab780a91efb1e819b328a
4
+ data.tar.gz: 6810b441c5758b0fee5efadda4616b2b67d8c6d8
5
5
  SHA512:
6
- metadata.gz: 615d1a7be21495edcfabe3d4884b637700c1ba032de7b8abc6cdd9d08c10abf00a1febcfc78ae98e6d4c2e0f25031c547326e6640fea561fc755236add5064e8
7
- data.tar.gz: 2ca11b3bdaa8d57adc40c7ca07aa5f790a306aeb8d88facacb6233031eaa7be2524bce10e921c775b93edb6720791f8842946a492d2603dc0857b39cc94b6784
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "dry-initializer"
3
- gem.version = "1.3.0"
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
- # definition for the getter method
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
@@ -51,7 +51,7 @@ module Dry::Initializer
51
51
  private :__initialize__
52
52
  private :__defaults__
53
53
  private :__coercers__
54
-
54
+
55
55
  #{getters}
56
56
  RUBY
57
57
  end
@@ -21,11 +21,6 @@ module Dry::Initializer
21
21
  " : #{undefined}"
22
22
  end
23
23
 
24
- def postsetter
25
- "@__options__[:#{target}] = @#{target}" \
26
- " unless @#{target} == #{undefined}"
27
- end
28
-
29
24
  # part of __defaults__
30
25
  def default_hash
31
26
  super :option
@@ -16,8 +16,6 @@ module Dry::Initializer
16
16
  safe_setter
17
17
  end
18
18
 
19
- def postsetter; end
20
-
21
19
  # part of __defaults__
22
20
  def default_hash
23
21
  super :param
@@ -1,23 +1,26 @@
1
1
  describe "@__options__" do
2
- context "when class has no options" do
2
+ context "when class has params" do
3
3
  before do
4
4
  class Test::Foo
5
- extend Dry::Initializer::Mixin
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 "is set to empty hash" do
11
- subject = Test::Foo.new(1)
12
+ it "collects coerced params with default values" do
13
+ subject = Test::Foo.new(:FOO)
12
14
 
13
- expect(subject.instance_variable_get(:@__options__)).to eq({})
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::Mixin
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.3.0
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-03-13 00:00:00.000000000 Z
12
+ date: 2017-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec