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: 6160f2952d35b381ccb85c48139a84187d975ec72297a13ba240656398610bb1
4
- data.tar.gz: d8aa690997677ddf8ae5bf2f219b00e5d7cad9bb0dcea89905f496bca2389072
3
+ metadata.gz: 64fb753de0bc41d6229e85e080565a7eb3cabce192a6cd89a3e07deb0add91f7
4
+ data.tar.gz: b40c7415b989ea2ce5dd9c46b0a986a4672f8c91764b7ba9dc0604c3ab451e5c
5
5
  SHA512:
6
- metadata.gz: 666753ee3a5ff1057d1d8b371d84b9a2510b0d89ce4a259ded6bdf0466f61f0009c18505f70bee8e92e65058cc1d460510cf9121ee3980845c3fd05936aa1f1f
7
- data.tar.gz: d543b184c95e126f6623e339dcfe17d6966aa19b50c19378701f250d45f599b4734f2bf0c0a194effb4af0bd194b88d244060076362e7e569215b1470cee0275
6
+ metadata.gz: f426600c0940004ac34514221aeac311edacd1e40221dcc030990350aa379fc43444a37995d2c1f3933929ecc4d611514e8127a66d6590518cb33f9a6011bc23
7
+ data.tar.gz: dfc8728bf7b03c7826ba050ca1e992ef700236a79bf34116ccf30e66d2d8850cfb2e81161387aa512b731ba61c7a59bf7857fbce7e913d6e56d365636266fc9a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.17)
4
+ ree_lib (1.0.18)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -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({
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.17"
4
+ VERSION = "1.0.18"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.17
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov