dry-initializer 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/dry-initializer.gemspec +1 -1
- data/lib/dry/initializer/mixin.rb +1 -0
- data/lib/dry/initializer/plugins/base.rb +1 -1
- data/lib/dry/initializer/plugins/variable_setter.rb +3 -2
- data/spec/renaming_options_spec.rb +2 -3
- data/spec/shared_definitions_spec.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92409ca11ac8b4f856593691a82b0fbeae8c48bf
|
4
|
+
data.tar.gz: f8176cbbfb30b21c3084ad5108791ff2062e094b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8c311f7daac997e3b08f86da46b31e40c9cd87a8ec0e9de14ff4d47679be2956cd009a11396aedd03f26e0455d9df149f2eb97582c90829459e517af9c8a21b
|
7
|
+
data.tar.gz: af5e325331c0dc37d4e160f90ffa59b608c21660bf919fa30f216c918203be548c165c909d1a28e9fcbcfeac6d30a38bc53bdd0623614976972921c5837aa3c5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## v0.9.3 2016-11-10
|
2
|
+
|
3
|
+
### Deprecated
|
4
|
+
|
5
|
+
* After discussion in [PR #17](https://github.com/dry-rb/dry-initializer/pull/17)
|
6
|
+
(many thanks to @sahal2080 and @hrom512 for starting that issue and PR),
|
7
|
+
the method `using` is deprecated and will be removed from v0.10.0 (@nepalez)
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
* Support of weird option names (@nepalez)
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
option :"First name", as: :first_name
|
15
|
+
```
|
16
|
+
|
17
|
+
[Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-initializer/compare/v0.9.2...v0.9.3)
|
18
|
+
|
1
19
|
## v0.9.2 2016-11-10
|
2
20
|
|
3
21
|
### Fixed
|
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 = "0.9.
|
3
|
+
gem.version = "0.9.3"
|
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"
|
@@ -42,7 +42,7 @@ module Dry::Initializer::Plugins
|
|
42
42
|
# Returns the name for the attribute
|
43
43
|
# @return (see .name)
|
44
44
|
def rename
|
45
|
-
@rename ||= settings[:option] ? settings[:as] || name : name
|
45
|
+
@rename ||= settings[:option] ? (settings[:as] || name) : name
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -22,8 +22,9 @@ module Dry::Initializer::Plugins
|
|
22
22
|
|
23
23
|
def call
|
24
24
|
return "@#{name} = #{name}" if param?
|
25
|
-
|
26
|
-
"@#{rename} = __options__.fetch(
|
25
|
+
key = ":\"#{name}\""
|
26
|
+
return "@#{rename} = __options__.fetch(#{key})" if required?
|
27
|
+
"@#{rename} = __options__.fetch(#{key}, Dry::Initializer::UNDEFINED)"
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -3,11 +3,11 @@ describe "renaming options" do
|
|
3
3
|
class Test::Foo
|
4
4
|
extend Dry::Initializer::Mixin
|
5
5
|
|
6
|
-
option :foo, as: :bar
|
6
|
+
option :"some foo", as: :bar
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
subject { Test::Foo.new foo: :BAZ }
|
10
|
+
subject { Test::Foo.new "some foo": :BAZ }
|
11
11
|
|
12
12
|
it "renames the attribute" do
|
13
13
|
expect(subject.bar).to eq :BAZ
|
@@ -16,6 +16,5 @@ describe "renaming options" do
|
|
16
16
|
|
17
17
|
it "renames the variable" do
|
18
18
|
expect(subject.instance_variable_get(:@bar)).to eq :BAZ
|
19
|
-
expect(subject.instance_variable_get(:@foo)).to be_nil
|
20
19
|
end
|
21
20
|
end
|
@@ -3,8 +3,12 @@ describe "shared definition" do
|
|
3
3
|
class Test::Foo
|
4
4
|
extend Dry::Initializer::Mixin
|
5
5
|
|
6
|
+
class << self
|
7
|
+
alias_method :attribute, :param
|
8
|
+
end
|
9
|
+
|
6
10
|
using default: proc { nil } do
|
7
|
-
|
11
|
+
attribute :foo
|
8
12
|
option :end
|
9
13
|
option :baz, default: proc { 0 }
|
10
14
|
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.9.
|
4
|
+
version: 0.9.3
|
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-
|
12
|
+
date: 2016-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -182,3 +182,4 @@ test_files:
|
|
182
182
|
- spec/type_argument_spec.rb
|
183
183
|
- spec/type_constraint_spec.rb
|
184
184
|
- spec/value_coercion_via_dry_types_spec.rb
|
185
|
+
has_rdoc:
|