typed_params 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +1 -0
- data/lib/typed_params/mapper.rb +4 -4
- data/lib/typed_params/memoize.rb +2 -2
- data/lib/typed_params/schema.rb +1 -1
- data/lib/typed_params/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab9149f0354b3110bc3a5610b06785055ad0e3ec00cc5e352b2daef7be902178
|
4
|
+
data.tar.gz: a48c899da8bc5d9fa9ee1041a2e35ff8f2f942b9ff083f7bf42e18e34e7813a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dabec975049677e23ab38f91c121f8f83a2dab36b753c9ad58f0693ad31ce780122b503b4b7554f6afe36568e3a85ef8c4d559591a8205bbadc9740e5cfd4b9
|
7
|
+
data.tar.gz: a4c8be23f0472002c9e317924091b624ac7cd640f08bfc515f61db119b72d20d6312919a4f45b31b14560d8bde08dad55467be058422acd4f39e225b927fd539
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.1.1
|
4
|
+
|
5
|
+
- Fix compatibility with Ruby 3.3.0 due to [#20091](https://bugs.ruby-lang.org/issues/20091).
|
6
|
+
|
7
|
+
## 1.1.0
|
8
|
+
|
9
|
+
- Add memoization to `#typed_params` and `#typed_query` methods.
|
10
|
+
|
3
11
|
## 1.0.3
|
4
12
|
|
5
13
|
- Revert 0b0aaa6b66edd3e4c3336e51fa340592e7ef9e86.
|
@@ -18,4 +26,4 @@
|
|
18
26
|
|
19
27
|
## 0.2.0
|
20
28
|
|
21
|
-
- Test release.
|
29
|
+
- Test release.
|
data/README.md
CHANGED
@@ -110,6 +110,7 @@ _We're working on improving the docs._
|
|
110
110
|
- Reuse schemas across controllers by defining named schemas.
|
111
111
|
- Run validations on params, similar to active model validations.
|
112
112
|
- Run transforms on params before they hit your controller.
|
113
|
+
- Support formatters such as JSON:API.
|
113
114
|
|
114
115
|
## Usage
|
115
116
|
|
data/lib/typed_params/mapper.rb
CHANGED
@@ -47,7 +47,7 @@ module TypedParams
|
|
47
47
|
# │ 1 ││ 2 │ │ 5 │
|
48
48
|
# └───┘└───┘ └───┘
|
49
49
|
#
|
50
|
-
def depth_first_map(param, &)
|
50
|
+
def depth_first_map(param, &block)
|
51
51
|
return if param.nil?
|
52
52
|
|
53
53
|
# Postorder DFS, so we'll visit the children first.
|
@@ -55,12 +55,12 @@ module TypedParams
|
|
55
55
|
case param.schema.children
|
56
56
|
in Array if param.array?
|
57
57
|
if param.schema.indexed?
|
58
|
-
param.schema.children.each_with_index { |v, i| self.class.call(param[i], schema: v, controller:, &) }
|
58
|
+
param.schema.children.each_with_index { |v, i| self.class.call(param[i], schema: v, controller:, &block) }
|
59
59
|
else
|
60
|
-
param.value.each { |v| self.class.call(v, schema: param.schema.children.first, controller:, &) }
|
60
|
+
param.value.each { |v| self.class.call(v, schema: param.schema.children.first, controller:, &block) }
|
61
61
|
end
|
62
62
|
in Hash if param.hash?
|
63
|
-
param.schema.children.each { |k, v| self.class.call(param[k], schema: v, controller:, &) }
|
63
|
+
param.schema.children.each { |k, v| self.class.call(param[k], schema: v, controller:, &block) }
|
64
64
|
else
|
65
65
|
end
|
66
66
|
end
|
data/lib/typed_params/memoize.rb
CHANGED
@@ -34,7 +34,7 @@ module TypedParams
|
|
34
34
|
end
|
35
35
|
|
36
36
|
klass.singleton_class.send(:alias_method, :"unmemoized_#{method_name}", method_name)
|
37
|
-
klass.class_eval
|
37
|
+
klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
38
38
|
def self.#{method_name}(*args, **kwargs, &block)
|
39
39
|
key = args.hash ^ kwargs.hash ^ block.hash
|
40
40
|
|
@@ -72,7 +72,7 @@ module TypedParams
|
|
72
72
|
end
|
73
73
|
|
74
74
|
klass.alias_method :"unmemoized_#{method_name}", method_name
|
75
|
-
klass.class_eval
|
75
|
+
klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
76
76
|
def #{method_name}(*args, **kwargs, &block)
|
77
77
|
key = args.hash ^ kwargs.hash ^ block.hash
|
78
78
|
|
data/lib/typed_params/schema.rb
CHANGED
@@ -211,7 +211,7 @@ module TypedParams
|
|
211
211
|
|
212
212
|
##
|
213
213
|
# params defines multiple like-parameters for a hash schema.
|
214
|
-
def params(*keys, **kwargs, &) = keys.each { param(_1, **kwargs, &) }
|
214
|
+
def params(*keys, **kwargs, &block) = keys.each { param(_1, **kwargs, &block) }
|
215
215
|
|
216
216
|
##
|
217
217
|
# item defines an indexed parameter for an array schema.
|
data/lib/typed_params/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typed_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zeke Gabrielse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|