pack_api 1.0.11 → 1.0.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: 60ffd472512cc31d089307740bd4126ee2e0a21153ef1d5ec31e1a93374b4278
4
- data.tar.gz: f85e543b0d98d63a9ad8bbe5ce3c87e4277421d417bcab46b367801bddba0693
3
+ metadata.gz: 202cffcdf9c46adf8f8228a91426a4b788db29370001ccaaeb28cf8bc8315b03
4
+ data.tar.gz: 60c10be7fc9ac5dcec8d045442ed9122eba404c363250c1d1b417065b93174dd
5
5
  SHA512:
6
- metadata.gz: 8b1e465d3c140343af94dfe1ed09ce260ca2aa1eebcd6dd4d6779a90426a7e999351809137517c5c473207f0a549aa1a6b07ee28732c3b077aa904e63af1df00
7
- data.tar.gz: a8aaab427e1c8e49c6d38236f22fde02df5d37699a302a1bcde300f6c36a1114ab93c7cea52504ab84f6927017891073a4370d6790b37555b731432744e09633
6
+ metadata.gz: 2c093365199196ec7372fecb715e55febae238bdc94db6ce9e940beff59057d15090c49ef60cb36e69d8447297f58a7e0e836559380e20b37988281af75a183f
7
+ data.tar.gz: b5a1242131bdedb8bce7918b05629d1be33703f58c2766803d5b91698a6349a23d76abf2a952e69b033ef2a5b73272d9311913d1ccd84c3c3070749a756c5e3d
@@ -32,7 +32,6 @@ module PackAPI::Pagination
32
32
  attr_accessor :query, :sort, :total_items, :per_page, :offset, :metadata
33
33
 
34
34
  DEFAULT_PER_PAGE = 20
35
- DEFAULT_SORT = 'id asc'
36
35
 
37
36
  ###
38
37
  # The range of items included in the results.
@@ -25,6 +25,8 @@
25
25
  #
26
26
  module PackAPI::Pagination
27
27
  class PaginatorBuilder
28
+ DEFAULT_SORT = 'id asc'
29
+
28
30
  attr_accessor :paginator
29
31
 
30
32
  def self.build
@@ -65,7 +67,7 @@ module PackAPI::Pagination
65
67
  @recordset_changed = original_query.to_json != @paginator.query.to_json
66
68
  end
67
69
 
68
- @paginator.sort ||= Paginator::DEFAULT_SORT
70
+ @paginator.sort ||= DEFAULT_SORT
69
71
  if sort.present?
70
72
  @recordset_changed = sort.to_json != @paginator.sort.to_json
71
73
  @paginator.sort = sort.presence
@@ -6,10 +6,17 @@ module PackAPI::Querying
6
6
  class_methods do
7
7
  def type = :dynamic_enum
8
8
 
9
- def search_for_options(relation:, search:) = raise NotImplementedError
9
+ ###
10
+ # Retrieve options for this filter based on user input.
11
+ # @param relation [ActiveRecord::Relation] The base relation to query against for options.
12
+ # @param search [String, nil] An optional search term to filter options by (using wildcard matching)
13
+ # @param value [String, Array<String>, nil] An optional value or array of values to filter options by (exact match)
14
+ def dynamic_options(relation:, search: nil, value: nil) = raise NotImplementedError
10
15
 
11
16
  private
12
17
 
18
+ ###
19
+ # Static filter options is an empty array.
13
20
  def filter_options(**) = PackAPI::FrozenEmpty::ARRAY
14
21
  end
15
22
  end
@@ -4,6 +4,7 @@ module PackAPI::Types
4
4
  class CollectionResultMetadata < Dry::Struct
5
5
  attribute :first_item, Types::Integer
6
6
  attribute :last_item, Types::Integer
7
+ attribute :per_page, Types::Integer
7
8
  attribute :total_items, Types::Integer
8
9
 
9
10
  ###
@@ -25,7 +26,8 @@ module PackAPI::Types
25
26
  new(
26
27
  first_item: 1,
27
28
  last_item: 1,
28
- total_items: 1
29
+ total_items: 1,
30
+ per_page: 1
29
31
  )
30
32
  end
31
33
 
@@ -34,6 +36,7 @@ module PackAPI::Types
34
36
  first_item: paginator.item_range.begin,
35
37
  last_item: paginator.item_range.end,
36
38
  total_items: paginator.total_items,
39
+ per_page: paginator.per_page,
37
40
  next_page_cursor: paginator.next_page_cursor,
38
41
  previous_page_cursor: paginator.previous_page_cursor,
39
42
  current_page_cursor: paginator.current_page_cursor,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PackAPI
4
- VERSION = "1.0.11"
4
+ VERSION = "1.0.13"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pack_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flytedesk