grape-listing 2.0.0.pre.beta.11 → 2.0.0.pre.beta.13

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: 0542abc140bd6936b962517da4c0650550f7a3f3624940b606f541ec2233d190
4
- data.tar.gz: a6764a6a57d82189558fe2b04426a3a0c961c2e580f5f2c6f28696f3ac8cce40
3
+ metadata.gz: 2728296b805a8877461c3696a08b7f604301b04911dc23690c38e4662d49e4e4
4
+ data.tar.gz: 8621fc8d53b6c608c85fab5a5231ce8a5e95446a0b424c3f2d4154b609f1a142
5
5
  SHA512:
6
- metadata.gz: 9c795d32967d973bad49a50450431df75f7ab6c416a88362d4ecd6eaa554acef1b2116feb6f3c77b44694fa5115e3a855b756f7c1b15068558c6a20d69e03fc5
7
- data.tar.gz: 9ae96a0514bfd032b39570cbd088e8286ffca3b8a8943e486eddc1a25a7f91f206b4b173da709b4f8061cc173ec79ebabac6d00e608691e8ae761ec1ee6f53ce
6
+ metadata.gz: b5faf00132b016257f6bf72790f17e3f8a6ce986a75b5d335569ba6335e1a6cbdf80dd344ce348be1fe9c559e1c5074df665b3b6f2acebf18bdf6b4a953d2766
7
+ data.tar.gz: 91d2b3865e241d629e3377dd5e9770389f6f37f676b4947ee30c19becbbdba1949de59152b6eafb12a2ee1ee3eec0950d87228447c41896d7a7796561fa58bbf
@@ -1,3 +1,3 @@
1
1
  module GrapeListing
2
- VERSION = '2.0.0-beta.11'.freeze
2
+ VERSION = '2.0.0-beta.13'.freeze
3
3
  end
@@ -10,8 +10,8 @@ module GrapeListing
10
10
 
11
11
  # результат с пагинацией
12
12
  {
13
- sort_by: @sort_by,
14
- sort_order: @sort_order,
13
+ sort_by: @params['sort_by'] || 'id',
14
+ sort_order: @params['sort_order'] || 'desc',
15
15
  count: @objects_count,
16
16
  objects: @objects
17
17
  }
@@ -91,6 +91,8 @@ module GrapeListing
91
91
  string_start(subject, condition, value)
92
92
  when END_WITH
93
93
  string_end(subject, condition, value)
94
+ when IN
95
+ string_in(subject, condition, value)
94
96
  end
95
97
  end
96
98
 
@@ -199,6 +201,17 @@ module GrapeListing
199
201
  end
200
202
  end
201
203
 
204
+ def string_in(subject, condition, value)
205
+ opts = value.map { |i| "'#{i}'" }.join(',')
206
+
207
+ case condition
208
+ when IS
209
+ "#{subject} IN (#{opts})"
210
+ when NOT
211
+ "#{subject} NOT IN (#{opts})"
212
+ end
213
+ end
214
+
202
215
  def number_present(subject, condition)
203
216
  case condition
204
217
  when IS
@@ -4,15 +4,15 @@ module GrapeListing
4
4
  private
5
5
 
6
6
  def sort_proc
7
- @sort_by = @params['sort_by'] || 'id'
8
- @sort_order = @params['sort_order'] || 'desc'
9
- custom_scope = @custom_sort[@sort_by] if @custom_sort
7
+ sort_by = @params['sort_by'] || 'id'
8
+ sort_order = @params['sort_order'] || 'desc'
9
+ custom_scope = @custom_sort[sort_by] if @custom_sort
10
10
 
11
11
  if custom_scope
12
- proc { send(custom_scope, @sort_order) }
12
+ proc { send(custom_scope, sort_order) }
13
13
  else
14
- nulls_order = @sort_order.to_s.downcase == 'desc' ? 'LAST' : 'FIRST'
15
- query = Arel.sql("#{@model.table_name}.#{@sort_by} #{@sort_order} NULLS #{nulls_order}")
14
+ nulls_order = sort_order.to_s.downcase == 'desc' ? 'LAST' : 'FIRST'
15
+ query = Arel.sql("#{@model.table_name}.#{sort_by} #{sort_order} NULLS #{nulls_order}")
16
16
  proc { order(query) }
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-listing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.beta.11
4
+ version: 2.0.0.pre.beta.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Павел Бабин
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-18 00:00:00.000000000 Z
11
+ date: 2025-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack