dry-interface 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dry/concrete/extensions/default.rb +2 -2
- data/lib/dry/concrete/value.rb +2 -1
- data/lib/dry/concrete.rb +4 -11
- data/lib/dry/interface/interfaces/unit.rb +2 -1
- data/lib/dry/interface.rb +2 -2
- data/lib/dry/value.rb +2 -1
- data/lib/dry.rb +2 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4079619043b7b01b90eb4b6def6b3c6ce28280bbb9597d0bb62ee4791fc37110
|
4
|
+
data.tar.gz: bef3b4af52fb863ab59402ab196f0909bffbfc3408c3898976f07d47d13c3813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8770345dae87d66406df5d677ecde817b69384d0ae1a7ebe355528d45e2800856821463349fdd262d1240231fb0f94d54f946d72b3160286087bb059b63e827b
|
7
|
+
data.tar.gz: dd28081ce094249862cffb93325908c90a813eac687c74f95ad91441db9493917fb84d5f15c131202542e281240b6cbf6f4ba8b31d30be61c72dc1a6fb81dd72
|
@@ -10,7 +10,7 @@ module Dry
|
|
10
10
|
#
|
11
11
|
# @return [#call(Dry::Types::Type)]
|
12
12
|
def to_default
|
13
|
-
->
|
13
|
+
-> type { type[call] }.freeze
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -20,7 +20,7 @@ module Dry
|
|
20
20
|
#
|
21
21
|
# @return [#call(Dry::Types::Type)]
|
22
22
|
def to_default
|
23
|
-
->
|
23
|
+
-> type = Dry::Types["any"] { type[self] }.to_default
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/dry/concrete/value.rb
CHANGED
@@ -12,7 +12,8 @@ module Dry
|
|
12
12
|
in [] then raise ArgumentError, "[#{self}] has no attributes, one is required"
|
13
13
|
in [key] then super({ key => value }, *other, &block)
|
14
14
|
else
|
15
|
-
raise ArgumentError,
|
15
|
+
raise ArgumentError,
|
16
|
+
"[#{self}] has more than one attribute: #{attribute_names.join(', ')}"
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
data/lib/dry/concrete.rb
CHANGED
@@ -30,17 +30,10 @@ module Dry
|
|
30
30
|
|
31
31
|
config.order = Hash.new(-1)
|
32
32
|
|
33
|
-
delegate(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Constant
|
38
|
-
Nominal
|
39
|
-
Value
|
40
|
-
Array
|
41
|
-
Hash
|
42
|
-
Any
|
43
|
-
], to: :Types)
|
33
|
+
delegate(
|
34
|
+
:Constructor, :Interface, :Instance, :Constant,
|
35
|
+
:Nominal, :Value, :Array, :Hash, :Any, to: :Types
|
36
|
+
)
|
44
37
|
|
45
38
|
def self.initializer(owner, &block)
|
46
39
|
owner.schema owner.schema.constructor(&block)
|
@@ -38,7 +38,8 @@ module Dry
|
|
38
38
|
in [] then raise ArgumentError, "[#{self}] has no attributes, one is required"
|
39
39
|
in [key] then _new({ key => value }, *other, &block)
|
40
40
|
else
|
41
|
-
raise ArgumentError,
|
41
|
+
raise ArgumentError,
|
42
|
+
"[#{self}] has more than one attribute: #{attribute_names.join(', ')}"
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
data/lib/dry/interface.rb
CHANGED
@@ -43,7 +43,7 @@ module Dry
|
|
43
43
|
|
44
44
|
# @return [String]
|
45
45
|
def self.to_s
|
46
|
-
|
46
|
+
"%s<[%s]>" % [name, subtypes.map(&:to_s).join(" | ")]
|
47
47
|
end
|
48
48
|
|
49
49
|
def self.reduce(input, subtype)
|
@@ -65,7 +65,7 @@ module Dry
|
|
65
65
|
# @return [Dry::Struct::Sum, Dry::Struct::Class]
|
66
66
|
def self.subtype
|
67
67
|
Constructor(self) do |value, _type, &error|
|
68
|
-
error ||=
|
68
|
+
error ||= -> error do
|
69
69
|
raise error
|
70
70
|
end
|
71
71
|
|
data/lib/dry/value.rb
CHANGED
@@ -13,7 +13,8 @@ module Dry
|
|
13
13
|
in [] then raise ArgumentError, "[#{self}] has no attributes, one is required"
|
14
14
|
in [key] then super({ key => value }, *other, &block)
|
15
15
|
else
|
16
|
-
raise ArgumentError,
|
16
|
+
raise ArgumentError,
|
17
|
+
"[#{self}] has more than one attribute: #{attribute_names.join(', ')}"
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/dry.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-interface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Linus Oleander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,14 +86,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '2.7'
|
90
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.2
|
96
|
+
rubygems_version: 3.1.2
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Dry::Interface
|