fetcheable_on_api 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fetcheable_on_api/filterable.rb +39 -5
- data/lib/fetcheable_on_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c8b3e1cde6dd4ff93a530ec0ce6bd00a493ae973f9af3aa83e07a45fabf31a1
|
4
|
+
data.tar.gz: 7c187a963ce2dc801ebc031b635ab0af5ee7bacf10c2db4a028d283cdd409d1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e1bb3204354fe86f02942e5346280fb5527be7b6c53772f94173d25d832bf508bde56f852c684e84f4f0a9279ce0490f747a6af85f45e45d4462bce823f3a64
|
7
|
+
data.tar.gz: '01937582df6570827c0aec8c314b963f1d427019daa00c0f8f135e62c60316fd0e5e15433d7e22568f89b309d9ed0a4e6646894b50e7426549f31ba6404d3e62'
|
data/Gemfile.lock
CHANGED
@@ -248,22 +248,29 @@ module FetcheableOnApi
|
|
248
248
|
if %i[between not_between].include?(predicate)
|
249
249
|
if values.is_a?(String)
|
250
250
|
# Single range: "start,end"
|
251
|
-
|
251
|
+
range_values = values.split(',')
|
252
|
+
range_values = apply_format_conversion(range_values, format)
|
253
|
+
predicates(predicate, collection, klass, column_name, range_values)
|
252
254
|
else
|
253
255
|
# Multiple ranges: ["start1,end1", "start2,end2"] with OR logic
|
254
256
|
values.map do |value|
|
255
|
-
|
257
|
+
range_values = value.split(',')
|
258
|
+
range_values = apply_format_conversion(range_values, format)
|
259
|
+
predicates(predicate, collection, klass, column_name, range_values)
|
256
260
|
end.inject(:or)
|
257
261
|
end
|
258
262
|
elsif values.is_a?(String)
|
259
263
|
# Single value or comma-separated values with OR logic
|
260
|
-
values.split(',')
|
264
|
+
split_values = values.split(',')
|
265
|
+
split_values = apply_format_conversion(split_values, format)
|
266
|
+
split_values.map do |value|
|
261
267
|
predicates(predicate, collection, klass, column_name, value)
|
262
268
|
end.inject(:or)
|
263
269
|
else
|
264
270
|
# Array of values, each potentially comma-separated
|
265
|
-
values.map
|
266
|
-
|
271
|
+
flat_values = values.map { |el| el.split(',') }.flatten
|
272
|
+
converted_values = apply_format_conversion(flat_values, format)
|
273
|
+
predicates(predicate, collection, klass, column_name, converted_values)
|
267
274
|
end
|
268
275
|
end
|
269
276
|
|
@@ -396,6 +403,33 @@ module FetcheableOnApi
|
|
396
403
|
end
|
397
404
|
end
|
398
405
|
|
406
|
+
# Apply format conversion to values based on the specified format.
|
407
|
+
# This method handles value transformation for different data types,
|
408
|
+
# particularly datetime conversion using the foa_string_to_datetime method.
|
409
|
+
#
|
410
|
+
# @param values [Object] The values to convert (String, Array, etc.)
|
411
|
+
# @param format [Symbol] The format to apply (:string, :array, :datetime)
|
412
|
+
# @return [Object] The converted values
|
413
|
+
# @private
|
414
|
+
def apply_format_conversion(values, format)
|
415
|
+
case format
|
416
|
+
when :datetime
|
417
|
+
if values.is_a?(Array)
|
418
|
+
values.map { |value| foa_string_to_datetime(value.to_s) }
|
419
|
+
elsif values.is_a?(String)
|
420
|
+
foa_string_to_datetime(values)
|
421
|
+
else
|
422
|
+
values
|
423
|
+
end
|
424
|
+
when :array
|
425
|
+
# Array format is handled in parameter parsing, not value conversion
|
426
|
+
values
|
427
|
+
else
|
428
|
+
# :string or any other format - no conversion needed
|
429
|
+
values
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
399
433
|
# Override the default permitted types to allow Arrays for filter parameters.
|
400
434
|
# Filtering supports more flexible parameter types compared to sorting/pagination
|
401
435
|
# since filter values can be arrays of values for certain predicates.
|