ree_lib 1.0.17 → 1.0.18
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64fb753de0bc41d6229e85e080565a7eb3cabce192a6cd89a3e07deb0add91f7
|
4
|
+
data.tar.gz: b40c7415b989ea2ce5dd9c46b0a986a4672f8c91764b7ba9dc0604c3ab451e5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f426600c0940004ac34514221aeac311edacd1e40221dcc030990350aa379fc43444a37995d2c1f3933929ecc4d611514e8127a66d6590518cb33f9a6011bc23
|
7
|
+
data.tar.gz: dfc8728bf7b03c7826ba050ca1e992ef700236a79bf34116ccf30e66d2d8850cfb2e81161387aa512b731ba61c7a59bf7857fbce7e913d6e56d365636266fc9a
|
data/Gemfile.lock
CHANGED
@@ -34,25 +34,27 @@ module ReeEnum
|
|
34
34
|
contract(
|
35
35
|
ReeEnum::Value,
|
36
36
|
Kwargs[
|
37
|
+
name: String,
|
37
38
|
role: Nilor[Symbol, ArrayOf[Symbol]]
|
38
39
|
] => String
|
39
40
|
)
|
40
|
-
def serialize(value, role: nil)
|
41
|
+
def serialize(value, name:, role: nil)
|
41
42
|
value.to_s
|
42
43
|
end
|
43
44
|
|
44
45
|
contract(
|
45
46
|
Any,
|
46
47
|
Kwargs[
|
48
|
+
name: String,
|
47
49
|
role: Nilor[Symbol, ArrayOf[Symbol]]
|
48
50
|
] => ReeEnum::Value
|
49
51
|
).throws(ReeMapper::CoercionError)
|
50
|
-
def cast(value, role: nil)
|
52
|
+
def cast(value, name:, role: nil)
|
51
53
|
if value.is_a?(String)
|
52
54
|
enum_val = @enum.values.all.detect { |v| v.to_s == value }
|
53
55
|
|
54
56
|
if !enum_val
|
55
|
-
raise ReeMapper::CoercionError, "should be one of #{@enum.values.all.map(&:to_s).inspect}"
|
57
|
+
raise ReeMapper::CoercionError, "`#{name}` should be one of #{@enum.values.all.map(&:to_s).inspect}"
|
56
58
|
end
|
57
59
|
|
58
60
|
enum_val
|
@@ -60,33 +62,35 @@ module ReeEnum
|
|
60
62
|
enum_val = @enum.values.all.detect { |v| v.to_i == value }
|
61
63
|
|
62
64
|
if !enum_val
|
63
|
-
raise ReeMapper::CoercionError, "should be one of #{@enum.values.all.map(&:to_s).inspect}"
|
65
|
+
raise ReeMapper::CoercionError, "`#{name}` should be one of #{@enum.values.all.map(&:to_s).inspect}"
|
64
66
|
end
|
65
67
|
|
66
68
|
enum_val
|
67
69
|
else
|
68
|
-
raise ReeMapper::CoercionError, "should be one of #{@enum.values.all.map(&:to_s).inspect}"
|
70
|
+
raise ReeMapper::CoercionError, "`#{name}` should be one of #{@enum.values.all.map(&:to_s).inspect}"
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
72
74
|
contract(
|
73
75
|
ReeEnum::Value,
|
74
76
|
Kwargs[
|
77
|
+
name: String,
|
75
78
|
role: Nilor[Symbol, ArrayOf[Symbol]]
|
76
79
|
] => Integer
|
77
80
|
)
|
78
|
-
def db_dump(value, role: nil)
|
81
|
+
def db_dump(value, name:, role: nil)
|
79
82
|
value.to_i
|
80
83
|
end
|
81
84
|
|
82
85
|
contract(
|
83
86
|
Integer,
|
84
87
|
Kwargs[
|
88
|
+
name: String,
|
85
89
|
role: Nilor[Symbol, ArrayOf[Symbol]]
|
86
90
|
] => ReeEnum::Value
|
87
91
|
).throws(ReeMapper::TypeError)
|
88
|
-
def db_load(value, role: nil)
|
89
|
-
cast(value, role: role)
|
92
|
+
def db_load(value, name:, role: nil)
|
93
|
+
cast(value, name: name, role: role)
|
90
94
|
end
|
91
95
|
end
|
92
96
|
|
@@ -112,7 +112,7 @@ RSpec.describe ReeEnum::DSL do
|
|
112
112
|
state: 'first',
|
113
113
|
type: 'invalid',
|
114
114
|
})
|
115
|
-
}.to raise_error(ReeMapper::CoercionError, 'should be one of ["account"]')
|
115
|
+
}.to raise_error(ReeMapper::CoercionError, '`type` should be one of ["account"]')
|
116
116
|
|
117
117
|
expect(
|
118
118
|
mapper.cast({
|
data/lib/ree_lib/version.rb
CHANGED