smart_params 6.0.0 → 6.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/smart_params/fluent_language.rb +3 -3
- data/lib/smart_params/missing_type_annotation_exception.rb +16 -0
- data/lib/smart_params/path_already_defined_exception.rb +14 -0
- data/lib/smart_params/version.rb +1 -1
- data/lib/smart_params.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5ead1f80985549897380d25e83f63f5d144bd06c55a5f390f3b985a463e7c5a
|
4
|
+
data.tar.gz: 76b95dc4979d190fb74d98fb341806f126ccce4f53c686b845bb5e90906e7c52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
data/lib/smart_params/version.rb
CHANGED
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.
|
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
|