api_only_pagination 0.1.2 → 0.1.4
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/api_only_pagination/active_record_paginate.rb +12 -11
- data/lib/api_only_pagination/paginate.rb +7 -0
- data/lib/api_only_pagination/version.rb +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: 826fde0fb392a394358a65a5759171b45cc47f449785bf2877d6728f7dfb4f0e
|
4
|
+
data.tar.gz: 1b13d3e52a7cdac0de53a8a54c5751283fb5e6419fdf0ac85457b74124b0e600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14eb5e9588e159cc148149135bdc6ef7b2b6879394300d4aa71d6da36fc7fe8049357aab703c9f2e3488fc7290c9671bede4eda9c9b2562fbb875d962b25935a
|
7
|
+
data.tar.gz: 47d8acd2be2b1f6ea72a689124156e9728404be2214232782fa733b01912e8a6875f0c62bd67eecba7c4b784d21d92ad0d5697b4f1cde2975d47e95eb3872bd5
|
data/Gemfile.lock
CHANGED
@@ -6,18 +6,19 @@ module ApiOnlyPagination
|
|
6
6
|
module ActiveRecordPaginate
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
module ClassMethods
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
%i[do_paginate paginate paginated_response].each do |access_method|
|
10
|
+
define_method(access_method) do |page = ApiOnlyPagination.configuration.default_page, per_page = ApiOnlyPagination.configuration.default_page_size| # or even |*args|
|
11
|
+
pagination = ApiOnlyPagination::Pagination.new(all, { page: page, per_page: per_page })
|
12
|
+
meta_data = pagination.metadata
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
ApiOnlyPagination::PaginatedData
|
15
|
+
.new(data: pagination.results,
|
16
|
+
per_page: meta_data.per_page,
|
17
|
+
current_page: meta_data.page,
|
18
|
+
total_pages: meta_data.total_pages,
|
19
|
+
total_records: meta_data.count)
|
20
|
+
end
|
21
|
+
end
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -9,6 +9,13 @@ module ApiOnlyPagination
|
|
9
9
|
@count = count
|
10
10
|
@per_page = [(per_page.to_i || ApiOnlyPagination.configuration.default_page_size),
|
11
11
|
ApiOnlyPagination.configuration.max_per_page].min
|
12
|
+
|
13
|
+
validate_params
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate_params
|
17
|
+
@page = @page.zero? ? ApiOnlyPagination.configuration.default_page : @page
|
18
|
+
@per_page = @per_page.zero? ? ApiOnlyPagination.configuration.default_page_size : @per_page
|
12
19
|
end
|
13
20
|
|
14
21
|
def offset
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_only_pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashok
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|