dry-initializer 0.10.0 → 0.10.1

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: a4d76d7f8289370012fd8520cbfc7b2b8375b6a3
4
- data.tar.gz: d39b5808176f0402dbeff16f18a223d179eb3a2f
3
+ metadata.gz: 703f60031e8175b459409542ce364d243e74176c
4
+ data.tar.gz: 7397c054e19e469e5d3aff41f6ee4ea2a051b28c
5
5
  SHA512:
6
- metadata.gz: 8f1676fe465def4eb3a91f332b17115b3f0bc0968233ca092fad22279e8cc3e23e6d9d43cffbd57e2bc2978fb60971eecb3e2f5d16ebb78f3f372784c996c570
7
- data.tar.gz: 8ea22e40b1847f4430b9fec4ab3bcce0af62e2cb864496a2c486f17b15165519b0a5b42bb043c548e557a33516e0888cb67023c0446d23b24649239b66757d64
6
+ metadata.gz: 230abf76b90e2f32c5435652e90990231698fce5237ff23b12b4a87091292e9fa8aa7cefa8527357cdece57c563d22c11136cc179bf3e875a39fd45a9a4ad530
7
+ data.tar.gz: 26c23b5a2ca43c0de31110d24a0253140433d6a8b4e0d21ccabb8a2fc879fff899d99e4da04c91662da5e782e321774563379d64e25626c5b0f7948979c70e09
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## v0.10.1 2016-12-27
2
+
3
+ ### Fixed
4
+
5
+ * Wrong arity when there were no options and the last param had a default (@nolith)
6
+
7
+ [Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-initializer/compare/v0.10.0...v0.10.1)
8
+
1
9
  ## v0.10.0 2016-11-20
2
10
 
3
11
  ### Deleted (BREAKING CHANGE!)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "dry-initializer"
3
- gem.version = "0.10.0"
3
+ gem.version = "0.10.1"
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"
@@ -36,8 +36,7 @@ module Dry::Initializer::Plugins
36
36
 
37
37
  # Builds a chunk of code
38
38
  # @return (see .call)
39
- def call
40
- end
39
+ def call; end
41
40
 
42
41
  # Returns the name for the attribute
43
42
  # @return (see .name)
@@ -25,7 +25,8 @@ module Dry::Initializer
25
25
  end
26
26
 
27
27
  def call
28
- (select(&:param?).map(&:call) + %w(**__options__)).compact.join(", ")
28
+ options = all?(&:param?) ? %w(__options__={}) : %w(**__options__)
29
+ (select(&:param?).map(&:call) + options).compact.join(", ")
29
30
  end
30
31
 
31
32
  private
@@ -48,4 +48,36 @@ describe "default values" do
48
48
  subject = Test::Foo.new
49
49
  expect(subject.mox).to eql :MOX
50
50
  end
51
+
52
+ describe "when the last param has a default and there are no options" do
53
+ before do
54
+ class Test::Bar
55
+ extend Dry::Initializer::Mixin
56
+
57
+ param :foo
58
+ param :bar, default: proc { {} }
59
+ end
60
+ end
61
+
62
+ it "instantiate arguments" do
63
+ subject = Test::Bar.new(1, 2)
64
+
65
+ expect(subject.foo).to eql 1
66
+ expect(subject.bar).to eql 2
67
+ end
68
+
69
+ it "applies default values" do
70
+ subject = Test::Bar.new(1)
71
+
72
+ expect(subject.foo).to eql 1
73
+ expect(subject.bar).to eql({})
74
+ end
75
+
76
+ it "instantiate arguments also if the last is an hash" do
77
+ subject = Test::Bar.new(1, { baz: 2, qux: 3 })
78
+
79
+ expect(subject.foo).to eql 1
80
+ expect(subject.bar).to eql({ baz: 2, qux: 3 })
81
+ end
82
+ end
51
83
  end
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: 0.10.0
4
+ version: 0.10.1
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: 2016-11-20 00:00:00.000000000 Z
12
+ date: 2016-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.6.4
154
+ rubygems_version: 2.5.2
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: DSL for declaring params and options of the initializer
@@ -173,4 +173,3 @@ test_files:
173
173
  - spec/type_argument_spec.rb
174
174
  - spec/type_constraint_spec.rb
175
175
  - spec/value_coercion_via_dry_types_spec.rb
176
- has_rdoc: