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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 204213e15d42807d8bb56fccb5fc87cdc5ece5915bb01ac9b117cfc111d51fc1
4
- data.tar.gz: 8bb425ec48b7b84cd8f43444e47f88e7a459fa5f135a54aef36846d99557a0c7
3
+ metadata.gz: 4c8b3e1cde6dd4ff93a530ec0ce6bd00a493ae973f9af3aa83e07a45fabf31a1
4
+ data.tar.gz: 7c187a963ce2dc801ebc031b635ab0af5ee7bacf10c2db4a028d283cdd409d1a
5
5
  SHA512:
6
- metadata.gz: 662357c5bec2bd2ba08717ba1d5eba8f7e3ab8d5e68bcea6a7019eee657e95ebb83845478e83ad8a369f741c7e61a05d5ff61d80f2c85bd5253313031992b66f
7
- data.tar.gz: c9980e7009bcd25abbc620ac0c57ea716ec5887bb3f981df100e1f2a0ce270701a3d4b150ccb3c6e528a9f908b1f8b12b96119faf6bfa341373bf062da6c3198
6
+ metadata.gz: 4e1bb3204354fe86f02942e5346280fb5527be7b6c53772f94173d25d832bf508bde56f852c684e84f4f0a9279ce0490f747a6af85f45e45d4462bce823f3a64
7
+ data.tar.gz: '01937582df6570827c0aec8c314b963f1d427019daa00c0f8f135e62c60316fd0e5e15433d7e22568f89b309d9ed0a4e6646894b50e7426549f31ba6404d3e62'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fetcheable_on_api (0.5.0)
4
+ fetcheable_on_api (0.6.1)
5
5
  activesupport (>= 4.1)
6
6
 
7
7
  GEM
@@ -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
- predicates(predicate, collection, klass, column_name, values.split(','))
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
- predicates(predicate, collection, klass, column_name, value.split(','))
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(',').map do |value|
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! { |el| el.split(',') }
266
- predicates(predicate, collection, klass, column_name, values)
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.
@@ -5,5 +5,5 @@ module FetcheableOnApi
5
5
  # Follows semantic versioning (semver.org) principles.
6
6
  #
7
7
  # @return [String] The version string in format "MAJOR.MINOR.PATCH"
8
- VERSION = '0.5.0'.freeze
8
+ VERSION = '0.6.1'.freeze
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fetcheable_on_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabien