smart_params 6.0.0 → 6.0.1

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: 9f43877a67e8dd606f2f178c7d65f2ec41412f91dc4208cecc150ecfcaca7558
4
- data.tar.gz: 8b5cf703c4eacabaa863e6efd8d938f4f87b417dfc6de1c80e6c6b89c4cef9be
3
+ metadata.gz: f5a757ef69761d43ce38da683b79975b5f2a9f712ac79824cd386ea0d1c8b12f
4
+ data.tar.gz: a569e347394533b8466d49cf4c4ed9ac3b1df6a3a6997640d8a2a46aeb142541
5
5
  SHA512:
6
- metadata.gz: 4c3b9ae72f37f625a831a8b387457ee7f0425dabea293073b20df33796ec853af3e89f0d3279557640887ab743ae7673de3b620e691b4d5f0f050f41ef98a417
7
- data.tar.gz: 3739b636c5f29142877b459d7914293970bbc97da5aad7fb1d6ed9a7636bb69d467bfb7644164ec346328f12fb2f58958b03af26e1487d22352676d7e148972e
6
+ metadata.gz: 8d6e2886fa056a1d5d5f66a2af46eb0e0034d3a0adcb7d2c75d5f54e1663ea261f67da8b3ba0fb7ffd1bfc8c5ee8104f8aaf90315ffaf18bc954cb199be2cad0
7
+ data.tar.gz: 6fc0347f0a76bdc4ec4863924a3f29200563dd0f3550216294da9899f7a22fe8c46f508527b3d5fffad515c05377c758fc449ab1d164f75d1395726293679a3a
data/README.md CHANGED
@@ -136,7 +136,7 @@ Or install it yourself with:
136
136
 
137
137
  ## Contributing
138
138
 
139
- 1. Read the [Code of Conduct](/CONDUCT)
139
+ 1. Read the [Code of Conduct](/CONDUCT.md)
140
140
  2. Fork it
141
141
  3. Create your feature branch (`git checkout -b my-new-feature`)
142
142
  4. Test your code: `rake spec`
@@ -24,13 +24,13 @@ module SmartParams
24
24
  end
25
25
 
26
26
  private def field(prefix, name, type = nil, **)
27
- raise MissingTypeException if type.nil? && !block_given?
28
-
29
27
  root, *remaining = Kernel.Array(prefix)
30
28
 
31
29
  path = [root, *remaining, name]
32
30
 
33
- raise KeyAlreadyDefinedException.new(path:) if self.namespaces[root].any? { |field| field.path == path }
31
+ raise SmartParams::MissingTypeAnnotationException.new(path:) if type.nil? && !block_given?
32
+
33
+ raise SmartParams::PathAlreadyDefinedException.new(path:) if self.namespaces[root].any? { |field| field.path == path }
34
34
 
35
35
  self.namespaces[root] = [
36
36
  *self.namespaces[root],
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartParams
4
+ class MissingTypeAnnotationException < StandardError
5
+ attr_accessor :path
6
+
7
+ def initialize(path:)
8
+ @path = path
9
+ super(message)
10
+ end
11
+
12
+ def message
13
+ "/#{@path.join('/')} was expected to define a type or a block, but did neither"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartParams
4
+ class PathAlreadyDefinedException < StandardError
5
+ def initialize(path:)
6
+ @path = path
7
+ super(message)
8
+ end
9
+
10
+ def message
11
+ "/#{@path.join('/')} was already taken as a field path"
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmartParams
4
- VERSION = "6.0.0"
4
+ VERSION = "6.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurtis Rainbolt-Greene
@@ -54,8 +54,10 @@ files:
54
54
  - lib/smart_params/invalid_payload_exception.rb
55
55
  - lib/smart_params/invalid_property_type_exception.rb
56
56
  - lib/smart_params/missing_property_exception.rb
57
+ - lib/smart_params/missing_type_annotation_exception.rb
57
58
  - lib/smart_params/namespace_already_defined_exception.rb
58
59
  - lib/smart_params/no_matching_namespace_exception.rb
60
+ - lib/smart_params/path_already_defined_exception.rb
59
61
  - lib/smart_params/version.rb
60
62
  - lib/smart_params_spec.rb
61
63
  homepage: https://github.com/krainboltgreene/smart_params.rb