dry-initializer 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/dry/initializer/builders/attribute.rb +8 -14
- data/lib/dry/initializer/builders/initializer.rb +1 -1
- data/lib/dry/initializer/builders/reader.rb +2 -2
- data/lib/dry/initializer/config.rb +1 -1
- data/lib/dry/initializer/dispatchers/prepare_default.rb +2 -2
- data/lib/dry/initializer/mixin.rb +1 -1
- data/lib/dry/initializer/version.rb +1 -1
- data/lib/dry/initializer.rb +0 -1
- metadata +2 -3
- data/lib/dry/initializer/errors.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f8c224268e3e35d66bade7dde3eaa5cf3423d931e0755930f5086c2151ccfc1
|
4
|
+
data.tar.gz: 07275ac52d641a42609e47472c47b2f2e643e97e41a338ca4365ee2074ef8356
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e1275ca3ad8bec808814d88c3217ba8dd81e70a1c6de0a089560737edc2531f9aa9180fef77be430501ede727e414b9addc0cf4fd1345705923a7d729a0c6cb
|
7
|
+
data.tar.gz: afb4438bb4a9e26ea815166764a12c34309c1bbe53322a948dae9851c983d74f6e5e0696715ab2a7108552e1e3436123c4bb652aad74ba1a441aba4728cd970f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
+
## 3.1.1 2022-01-19
|
4
|
+
|
5
|
+
|
6
|
+
### Changed
|
7
|
+
|
8
|
+
- Improved error messages were rolled back, they created an implicit dependency on dry-types (@flash-gordon)
|
9
|
+
|
10
|
+
[Compare v3.1.0...v3.1.1](https://github.com/dry-rb/dry-initializer/compare/v3.1.0...v3.1.1)
|
11
|
+
|
3
12
|
## 3.1.0 2022-01-16
|
4
13
|
|
5
14
|
|
@@ -53,7 +53,7 @@ module Dry
|
|
53
53
|
|
54
54
|
def required_reader
|
55
55
|
"#{@val} = #{@opts}.fetch(:'#{@source}')" \
|
56
|
-
|
56
|
+
" { raise KeyError, \"\#{self.class}: #{@definition} is required\" }"
|
57
57
|
end
|
58
58
|
|
59
59
|
def definition_line
|
@@ -72,23 +72,17 @@ module Dry
|
|
72
72
|
return unless @type
|
73
73
|
|
74
74
|
arity = @type.is_a?(Proc) ? @type.arity : @type.method(:call).arity
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
#{@val} = #{@item}.type.call(#{type_call_params})
|
82
|
-
end
|
83
|
-
rescue Dry::Types::ConstraintError => e
|
84
|
-
raise Dry::Initializer::CoercionError.new(e, '#{@source}')
|
85
|
-
end
|
86
|
-
COERCE
|
75
|
+
|
76
|
+
if arity.equal?(1) || arity.negative?
|
77
|
+
"#{@val} = #{@item}.type.call(#{@val}) unless #{@null} == #{@val}"
|
78
|
+
else
|
79
|
+
"#{@val} = #{@item}.type.call(#{@val}, self) unless #{@null} == #{@val}"
|
80
|
+
end
|
87
81
|
end
|
88
82
|
|
89
83
|
def assignment_line
|
90
84
|
"#{@ivar} = #{@val}" \
|
91
|
-
|
85
|
+
" unless #{@null} == #{@val} && instance_variable_defined?(:#{@ivar})"
|
92
86
|
end
|
93
87
|
end
|
94
88
|
end
|
@@ -28,8 +28,8 @@ module Dry
|
|
28
28
|
|
29
29
|
def undef_line
|
30
30
|
"undef :#{@target} if method_defined?(:#{@target})" \
|
31
|
-
|
32
|
-
|
31
|
+
" || private_method_defined?(:#{@target})" \
|
32
|
+
" || protected_method_defined?(:#{@target})"
|
33
33
|
end
|
34
34
|
|
35
35
|
def attribute_line
|
@@ -38,8 +38,8 @@ module Dry
|
|
38
38
|
|
39
39
|
def invalid!(default)
|
40
40
|
raise TypeError, "The #{default.inspect} should be" \
|
41
|
-
|
42
|
-
|
41
|
+
" either convertable to proc with no arguments," \
|
42
|
+
" or respond to #call without arguments."
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -9,7 +9,7 @@ module Dry
|
|
9
9
|
# @deprecated
|
10
10
|
def self.extended(klass)
|
11
11
|
warn "[DEPRECATED] Use Dry::Initializer instead of its alias" \
|
12
|
-
|
12
|
+
" Dry::Initializer::Mixin. The later will be removed in v2.1.0"
|
13
13
|
super
|
14
14
|
end
|
15
15
|
|
data/lib/dry/initializer.rb
CHANGED
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: 3.1.
|
4
|
+
version: 3.1.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: 2022-01-
|
12
|
+
date: 2022-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -71,7 +71,6 @@ files:
|
|
71
71
|
- lib/dry/initializer/dispatchers/unwrap_type.rb
|
72
72
|
- lib/dry/initializer/dispatchers/wrap_type.rb
|
73
73
|
- lib/dry/initializer/dsl.rb
|
74
|
-
- lib/dry/initializer/errors.rb
|
75
74
|
- lib/dry/initializer/mixin.rb
|
76
75
|
- lib/dry/initializer/mixin/local.rb
|
77
76
|
- lib/dry/initializer/mixin/root.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Initializer
|
5
|
-
class CoercionError < ::StandardError
|
6
|
-
def initialize(constraint_error, field)
|
7
|
-
@constraint_error = constraint_error
|
8
|
-
@field = field
|
9
|
-
super(message)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Ensure that the field name is in the error message
|
13
|
-
def message
|
14
|
-
if @constraint_error.message =~ /#{@field}/
|
15
|
-
@constraint_error.message
|
16
|
-
else
|
17
|
-
"#{@constraint_error.message} for field :#{@field}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|