decanter 3.5.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/lib/decanter/configuration.rb +2 -1
- data/lib/decanter/core.rb +11 -1
- data/lib/decanter/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: 697f969bd6cdcac1487d237135cd4f1860ff9aa79abece975305d7ca7f0d5504
|
4
|
+
data.tar.gz: 7ab9d647d3c90e9c5186f4f0b486115b3d17f3107990a7984827d87e2f4843f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 286e79ac8ebdbd3b75cc667fadd77b2fc6966f54274f06e282fc9d94250cf3075eb2f6a9e31295f1d51efb50b1b5757507de98cc6816a23b9871af7c3e32ab2a
|
7
|
+
data.tar.gz: b4cfff1c6ba4acc7f3244674e6d2a741dfbee1d5e03cdf392365bcbe4ba684f4592e1921143e7041e28d600b67cc1814110ac973c809bbea5c076a872092c652
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -280,11 +280,14 @@ TripDecanter.decant({ name: 'Vacation 2020' })
|
|
280
280
|
|
281
281
|
You can generate a local copy of the default configuration with `rails generate decanter:install`. This will create an initializer where you can do global configuration:
|
282
282
|
|
283
|
+
Setting strict mode to :ignore will log out any unhandled keys. To avoid excessive logging, the global configuration can be set to `log_unhandled_keys = false`
|
284
|
+
|
283
285
|
```ruby
|
284
286
|
# ./config/initializers/decanter.rb
|
285
287
|
|
286
288
|
Decanter.config do |config|
|
287
289
|
config.strict = false
|
290
|
+
config.log_unhandled_keys = false
|
288
291
|
end
|
289
292
|
```
|
290
293
|
|
data/lib/decanter/core.rb
CHANGED
@@ -54,6 +54,11 @@ module Decanter
|
|
54
54
|
@strict_mode = mode
|
55
55
|
end
|
56
56
|
|
57
|
+
def log_unhandled_keys(mode)
|
58
|
+
raise(ArgumentError, "#{self.name}: Unknown log_unhandled_keys value #{mode}") unless [true, false].include? mode
|
59
|
+
@log_unhandled_keys_mode = mode
|
60
|
+
end
|
61
|
+
|
57
62
|
def decant(args)
|
58
63
|
return handle_empty_args if args.blank?
|
59
64
|
return empty_required_input_error unless required_input_keys_present?(args)
|
@@ -125,7 +130,7 @@ module Decanter
|
|
125
130
|
|
126
131
|
case strict_mode
|
127
132
|
when :ignore
|
128
|
-
p "#{self.name} ignoring unhandled keys: #{unhandled_keys.join(', ')}."
|
133
|
+
p "#{self.name} ignoring unhandled keys: #{unhandled_keys.join(', ')}." if log_unhandled_keys_mode
|
129
134
|
{}
|
130
135
|
when true
|
131
136
|
raise(UnhandledKeysError, "#{self.name} received unhandled keys: #{unhandled_keys.join(', ')}.")
|
@@ -229,6 +234,11 @@ module Decanter
|
|
229
234
|
@strict_mode.nil? ? Decanter.configuration.strict : @strict_mode
|
230
235
|
end
|
231
236
|
|
237
|
+
def log_unhandled_keys_mode
|
238
|
+
return !!(Decanter.configuration.log_unhandled_keys) if @log_unhandled_keys_mode.nil?
|
239
|
+
!!@log_unhandled_keys_mode
|
240
|
+
end
|
241
|
+
|
232
242
|
# Helpers
|
233
243
|
|
234
244
|
private
|
data/lib/decanter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decanter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Francis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-09-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|