gobl 0.8.0 → 0.9.0

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: 2ee8e2de79cf9e57ae8187c6877157c5028b39f6230578b07bef5cdb308f1860
4
- data.tar.gz: d11b23074bf2e2bd1510ffb0275f9e709a4e1c9abd1ed98fb0740fadba02a720
3
+ metadata.gz: 5e14eb326a6bbca1237cdc6782714e9dbcacbe53e3bcb0028e52acefbb83ea5b
4
+ data.tar.gz: fb366c4ba614d652d14938a7d99f85522db3dc2845b32b611fc78d8bb9761ead
5
5
  SHA512:
6
- metadata.gz: 15918f8e090b12328ad922cecb2b2ec5352c795683571ab83d2b27982f0c8c3928e6c7c7f15d4fee5f3f8a13a6846df3c964d938639c970d9b4e2ff696291380
7
- data.tar.gz: 568f54e8d72ad88f613736de1bc79c1787def71fc4592690f5ec884282b7f8fc335c6cc8dd767805875d6bdd5d5fadf84ba49ee0e9ec95cccf51eda039e751e6
6
+ metadata.gz: 2109bb654d767070f4261cd45b85d97bd7e7ebbb9d03ea83b8af5fd61f73434d0e5ebd2d13f35aa368d154d68fef3742116d8b405eec1611bd7799c410bce124
7
+ data.tar.gz: 63d05794780f7e4a200490b56f1477fb4fb14dc11e4aab0ce2e81358ff58d2f02175318e16f13ea46098edd1f8a045ceefe51de9a5b384913450a09103b5796f
@@ -24,9 +24,7 @@ module GOBL
24
24
  'self-billed' => 'Self billed invoice'
25
25
  }.freeze
26
26
 
27
- def strict_enum?
28
- true
29
- end
27
+ validates_inclusion_of :_value, in: ENUM.keys, message: '"%{value}" is not within the allowed values of the enumeration'
30
28
  end
31
29
  end
32
30
  end
@@ -42,9 +42,7 @@ module GOBL
42
42
  'tax' => 'Tax declaration'
43
43
  }.freeze
44
44
 
45
- def strict_enum?
46
- true
47
- end
45
+ validates_inclusion_of :_value, in: ENUM.keys, message: '"%{value}" is not within the allowed values of the enumeration'
48
46
  end
49
47
  end
50
48
  end
@@ -183,9 +183,7 @@ module GOBL
183
183
  'ZWL' => 'Zimbabwe Dollar'
184
184
  }.freeze
185
185
 
186
- def strict_enum?
187
- true
188
- end
186
+ validates_inclusion_of :_value, in: ENUM.keys, message: '"%{value}" is not within the allowed values of the enumeration'
189
187
  end
190
188
  end
191
189
  end
data/lib/gobl/enum.rb CHANGED
@@ -4,6 +4,8 @@ module GOBL
4
4
  # Base class for single value structures in the GOBL schema that have a controlled set
5
5
  # of values associated to them (i.e., an enumeration) that may constrain them
6
6
  class Enum < Value
7
+ include ActiveModel::Validations
8
+
7
9
  # Returns an enum value object that corresponds to a given value. The value can be a
8
10
  # `Symbol`, a `String` or anything coercible into one (via `#to_s`)
9
11
  #
@@ -62,18 +64,6 @@ module GOBL
62
64
 
63
65
  private
64
66
 
65
- def _value=(value)
66
- if strict_enum? && !self.class::ENUM.key?(value)
67
- raise TypeError, "\"#{value}\" is not within the valid values of the enumeration"
68
- end
69
-
70
- super
71
- end
72
-
73
- def strict_enum?
74
- false
75
- end
76
-
77
67
  def value_from_sym(sym)
78
68
  self.class.find_by_sym(sym)&.to_s
79
69
  end
@@ -266,9 +266,7 @@ module GOBL
266
266
  'ZW' => 'Zimbabwe'
267
267
  }.freeze
268
268
 
269
- def strict_enum?
270
- true
271
- end
269
+ validates_inclusion_of :_value, in: ENUM.keys, message: '"%{value}" is not within the allowed values of the enumeration'
272
270
  end
273
271
  end
274
272
  end
@@ -24,9 +24,7 @@ module GOBL
24
24
  'online' => 'Online or web payment'
25
25
  }.freeze
26
26
 
27
- def strict_enum?
28
- true
29
- end
27
+ validates_inclusion_of :_value, in: ENUM.keys, message: '"%{value}" is not within the allowed values of the enumeration'
30
28
  end
31
29
  end
32
30
  end
@@ -27,9 +27,7 @@ module GOBL
27
27
  'delivery' => 'Payment on Delivery'
28
28
  }.freeze
29
29
 
30
- def strict_enum?
31
- true
32
- end
30
+ validates_inclusion_of :_value, in: ENUM.keys, message: '"%{value}" is not within the allowed values of the enumeration'
33
31
  end
34
32
  end
35
33
  end
@@ -22,9 +22,7 @@ module GOBL
22
22
  'other' => 'An other type of source not listed'
23
23
  }.freeze
24
24
 
25
- def strict_enum?
26
- true
27
- end
25
+ validates_inclusion_of :_value, in: ENUM.keys, message: '"%{value}" is not within the allowed values of the enumeration'
28
26
  end
29
27
  end
30
28
  end
data/lib/gobl/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GOBL
4
- VERSION = '0.8.0'
4
+ VERSION = '0.9.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lilue
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-02-10 00:00:00.000000000 Z
13
+ date: 2023-03-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  - !ruby/object:Gem::Version
179
179
  version: 3.1.4
180
180
  requirements: []
181
- rubygems_version: 3.4.1
181
+ rubygems_version: 3.4.6
182
182
  signing_key:
183
183
  specification_version: 4
184
184
  summary: Minimalist ruby version of the GOBL library