salestation 4.6.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/salestation/web/extractors.rb +23 -4
- data/salestation.gemspec +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: 63f86b3537b2db5857f54ef439442a3ca0ef1a4f078d602989783814fd70b718
|
4
|
+
data.tar.gz: 2836da19672da049c461769c8482e4c9cab2e3ce6d6292293051639c0a0cb8e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc79ff3f36806274195543e4fc0e13f27d098d1239b3c0706cd6a7ed3f643a764a71b2b34426ccfbe19ebc9f29b0018a8c8619a1c2f9729c180df70a2b640906
|
7
|
+
data.tar.gz: 4b4d65d3e6158c9ff0025f2e5548b650dab2d0ca3bf4c5dca3f51b11943be552c44eadda05cb5830962157ef2d1200e8067b731eebbc74bb501d83e8a39d7753
|
@@ -197,12 +197,26 @@ module Salestation
|
|
197
197
|
when Symbol
|
198
198
|
stringified_key = filter.to_s
|
199
199
|
extracted_data[filter] = request_hash[stringified_key] if request_hash.key?(stringified_key)
|
200
|
+
if extracted_data[filter].is_a?(Array)
|
201
|
+
extracted_data[filter] = extracted_data[filter].map{ |hash|
|
202
|
+
if hash.is_a?(Hash)
|
203
|
+
hash.transform_keys(&:to_sym) if hash.is_a?(Hash)
|
204
|
+
else
|
205
|
+
hash
|
206
|
+
end
|
207
|
+
}
|
208
|
+
end
|
200
209
|
when Hash
|
201
210
|
filter.each do |key, nested_filters|
|
202
211
|
stringified_key = key.to_s
|
203
212
|
if request_hash.key?(stringified_key)
|
204
213
|
value = request_hash.fetch(stringified_key)
|
205
|
-
extracted_data[key] =
|
214
|
+
extracted_data[key] =
|
215
|
+
if !value.is_a?(Hash)
|
216
|
+
value
|
217
|
+
else
|
218
|
+
extract(nested_filters, value)
|
219
|
+
end
|
206
220
|
end
|
207
221
|
end
|
208
222
|
end
|
@@ -219,17 +233,22 @@ module Salestation
|
|
219
233
|
# Extracts and symbolizes params from request body
|
220
234
|
#
|
221
235
|
# @example
|
222
|
-
# extractor = BodyParamExtractor[:x, :y, {foo: [:bar, :baz]}]
|
236
|
+
# extractor = BodyParamExtractor[:x, :y, {foo: [:bar, :baz]}, :aaa]
|
223
237
|
# input = {
|
224
238
|
# 'x' => '1',
|
225
239
|
# 'y' => '2',
|
226
240
|
# 'z' => '3',
|
227
241
|
# 'foo' => {
|
228
242
|
# 'bar' => 'qq'
|
229
|
-
# }
|
243
|
+
# },
|
244
|
+
# 'aaa' => [
|
245
|
+
# {
|
246
|
+
# 'bb' => 'cc'
|
247
|
+
# }
|
248
|
+
# ]
|
230
249
|
# }
|
231
250
|
# # rack_request is Rack::Request with 'rack.request.form_hash' set to input
|
232
|
-
# extractor.call(rack_request).value #=> {x: 1, y: 2, foo: {bar: 'qq}}
|
251
|
+
# extractor.call(rack_request).value #=> {x: 1, y: 2, foo: {bar: 'qq'}, aaa: [{bb: 'cc'}]}
|
233
252
|
#
|
234
253
|
class BodyParamExtractor
|
235
254
|
def self.[](*filters)
|
data/salestation.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salestation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glia TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|