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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6ba2f5aec658ea03696c44adb78d7672dfbdff38e09bb180747df60c052806f
4
- data.tar.gz: 17b96fa105e034549bc1c27d6ed99cd4cc322a483a7c06a7248e01f980926c92
3
+ metadata.gz: 51307d488e1178966b88bac2344fbbdf03f0d99468d810c8c3d1b5f4337563be
4
+ data.tar.gz: 89a122fe01133ea7906a3edf35f3b8158ebe05d63377ae75783f06dfdc289482
5
5
  SHA512:
6
- metadata.gz: 2e0ec9ae013b8d240dfe0006d82d35cd954edad38813e2626e1a1eac2d414838f9afa415ff8b34c94a960afad83bb6e7d4b9bbf7e109c665e63d43453afb81d3
7
- data.tar.gz: a08bf1ce80d8fcb4078d86ca5b4b7dd8899ecfc045401dff5cc1a8dc659cae0cfc6a524c65a51a92fb1424641460cd021b940790f0650a9fbb1a931bdaf7e2f0
6
+ metadata.gz: be60295f1c9144554bad8cd96b99cf28c288ee6881a813af72c7c49ff6dbb84a73972ed0da21defccce6b7146b9454abeeadc5c0000aaea01c2f91be3448a5f2
7
+ data.tar.gz: ce85f9a928fb36067586e1ece4cd2372c4e97be76363ef31c2793581d718fcac5f48c010482b539fcff1cb0872bc97968414732a7a3ea1f5d88635de71ebf0b3
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmartParams
4
- VERSION = "4.0.1"
4
+ VERSION = "4.1.0"
5
5
  end
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:, &subfield)
100
- @schema = Field.new(keychain: [], type:, &subfield)
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.1
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-31 00:00:00.000000000 Z
11
+ date: 2023-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport