smart_params 4.0.0 → 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: aa09497154b8fcffacbdb4a2d90e277eb00ca8b159279eb3220532c7cb604160
4
- data.tar.gz: ace3cfdc1a43e66979a5a562b2458321892c1b93c1bc50a2790ebd07b6886c35
3
+ metadata.gz: 51307d488e1178966b88bac2344fbbdf03f0d99468d810c8c3d1b5f4337563be
4
+ data.tar.gz: 89a122fe01133ea7906a3edf35f3b8158ebe05d63377ae75783f06dfdc289482
5
5
  SHA512:
6
- metadata.gz: 94e685f378e35aa4098d88c2c110abc7f101e60223202746b06aa70f45ee648f5203d1c4cb526072747505b30475ffa092a92d8db4c4b20ae7011053414b6b75
7
- data.tar.gz: 7761f7c49ab88765088d92864fc81735499b57b2388e0286a9a90f11a57d73c68101f6fa215b58f6c330e601e7a6898e1097189983a8e4ce9ee05b1694e424ca
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.0"
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
@@ -60,7 +60,9 @@ module SmartParams
60
60
  delegate :dig, to: :to_hash
61
61
  delegate :to_s, to: :to_hash
62
62
 
63
- def respond_to_missing? = true
63
+ def respond_to_missing?(name, include_private = false)
64
+ payload.respond_to?(name) || super
65
+ end
64
66
 
65
67
  def method_missing(name, *arguments, &)
66
68
  if payload.respond_to?(name)
@@ -94,8 +96,9 @@ module SmartParams
94
96
  end
95
97
 
96
98
  class_methods do
97
- def schema(type:, &subfield)
98
- @schema = Field.new(keychain: [], type:, &subfield)
99
+ def schema(name: :default, type:, &definitions)
100
+ @schema ||= {}
101
+ @schema[name] = Field.new(keychain: [], type:, &definitions)
99
102
  end
100
103
  end
101
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.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-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