smart_params 4.0.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_params/version.rb +1 -1
- data/lib/smart_params.rb +5 -4
- 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: 51307d488e1178966b88bac2344fbbdf03f0d99468d810c8c3d1b5f4337563be
|
4
|
+
data.tar.gz: 89a122fe01133ea7906a3edf35f3b8158ebe05d63377ae75783f06dfdc289482
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be60295f1c9144554bad8cd96b99cf28c288ee6881a813af72c7c49ff6dbb84a73972ed0da21defccce6b7146b9454abeeadc5c0000aaea01c2f91be3448a5f2
|
7
|
+
data.tar.gz: ce85f9a928fb36067586e1ece4cd2372c4e97be76363ef31c2793581d718fcac5f48c010482b539fcff1cb0872bc97968414732a7a3ea1f5d88635de71ebf0b3
|
data/lib/smart_params/version.rb
CHANGED
data/lib/smart_params.rb
CHANGED
@@ -18,10 +18,10 @@ module SmartParams
|
|
18
18
|
attr_reader :schema
|
19
19
|
attr_reader :fields
|
20
20
|
|
21
|
-
def initialize(raw, safe: true)
|
21
|
+
def initialize(raw, safe: true, name: :default)
|
22
22
|
@safe = safe
|
23
23
|
@raw = raw
|
24
|
-
@schema = self.class.instance_variable_get(:@schema)
|
24
|
+
@schema = self.class.instance_variable_get(:@schema)[name]
|
25
25
|
|
26
26
|
@fields = [@schema, *unfold(@schema.subfields)].sort_by(&:weight).each { |field| field.claim(raw) }
|
27
27
|
rescue SmartParams::Error::InvalidPropertyType => e
|
@@ -96,8 +96,9 @@ module SmartParams
|
|
96
96
|
end
|
97
97
|
|
98
98
|
class_methods do
|
99
|
-
def schema(type:, &
|
100
|
-
@schema
|
99
|
+
def schema(name: :default, type:, &definitions)
|
100
|
+
@schema ||= {}
|
101
|
+
@schema[name] = Field.new(keychain: [], type:, &definitions)
|
101
102
|
end
|
102
103
|
end
|
103
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kurtis Rainbolt-Greene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08
|
11
|
+
date: 2023-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|