smart_params 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f43877a67e8dd606f2f178c7d65f2ec41412f91dc4208cecc150ecfcaca7558
4
- data.tar.gz: 8b5cf703c4eacabaa863e6efd8d938f4f87b417dfc6de1c80e6c6b89c4cef9be
3
+ metadata.gz: a5ead1f80985549897380d25e83f63f5d144bd06c55a5f390f3b985a463e7c5a
4
+ data.tar.gz: 76b95dc4979d190fb74d98fb341806f126ccce4f53c686b845bb5e90906e7c52
5
5
  SHA512:
6
- metadata.gz: 4c3b9ae72f37f625a831a8b387457ee7f0425dabea293073b20df33796ec853af3e89f0d3279557640887ab743ae7673de3b620e691b4d5f0f050f41ef98a417
7
- data.tar.gz: 3739b636c5f29142877b459d7914293970bbc97da5aad7fb1d6ed9a7636bb69d467bfb7644164ec346328f12fb2f58958b03af26e1487d22352676d7e148972e
6
+ metadata.gz: 4b0b5dd7fa36594d448335c13cfe8fb6800b499199e48f31c465e2b2057aeac68132c06a0388a15ea3cbf3f3254afb73668e6eb0f17d68b7957e3d3c98cef6ec
7
+ data.tar.gz: 66b24fa6d243a8ad46b35a58c2a28b64efc55bd4308e2ec26ece51011dd44f97f1e3f1f02a69a238a3b6ade4361786146ac30d123454854c3c5caca4f2021c8f
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.2"
5
5
  end
data/lib/smart_params.rb CHANGED
@@ -6,6 +6,8 @@ require "active_support/core_ext/object"
6
6
  require "active_support/core_ext/module"
7
7
 
8
8
  module SmartParams
9
+ require_relative "smart_params/missing_type_annotation_exception"
10
+ require_relative "smart_params/path_already_defined_exception"
9
11
  require_relative "smart_params/invalid_payload_exception"
10
12
  require_relative "smart_params/invalid_property_type_exception"
11
13
  require_relative "smart_params/missing_property_exception"
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.2
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