simple-sql 0.4.39 → 0.4.40
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/lib/simple/sql/result.rb +9 -7
- data/lib/simple/sql/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: b7aec21685ece83267046a3e9c9598034dc32f9d3abf5ae9e865086de2e0c76a
|
4
|
+
data.tar.gz: d7b7f03907c3227170051400fb9bd3c5a858158d0e547b3358cbb2f5313cba7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71b76a7de9e626e56a94f01c2243d55f208c0b26da08318b711aead2c484afcc056ec0d15312824b8f8ee269ade7ec00e8aa1fa93974345d31336b84637c865a
|
7
|
+
data.tar.gz: 5fe760ec0b14d8b1cc5ba87209130d12036bfd34eedf3ea3081597c5fb752cc322e656a00a66c0225f34e3334e272e75c0af3eb718a86cc78c2698d236efb278
|
data/lib/simple/sql/result.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# rubocop:disable Naming/AccessorMethodName
|
2
|
+
# rubocop:disable Style/DoubleNegation
|
3
|
+
# rubocop:disable Style/GuardClause
|
2
4
|
|
3
5
|
require_relative "helpers"
|
4
6
|
|
@@ -66,31 +68,31 @@ class ::Simple::SQL::Result < Array
|
|
66
68
|
end
|
67
69
|
|
68
70
|
def paginated?
|
69
|
-
|
71
|
+
!!@pagination_scope
|
70
72
|
end
|
71
73
|
|
72
74
|
private
|
73
75
|
|
74
76
|
def pagination_scope
|
75
77
|
raise "Only available only for paginated scopes" unless paginated?
|
76
|
-
|
78
|
+
|
77
79
|
@pagination_scope
|
78
80
|
end
|
79
81
|
|
80
82
|
def set_pagination_info(scope)
|
81
83
|
raise ArgumentError, "per must be > 0" unless scope.per > 0
|
82
84
|
|
85
|
+
@pagination_scope = scope
|
86
|
+
|
87
|
+
# This branch is an optimization: the call to the database to count is
|
88
|
+
# not necessary if we know that there are not even any results on the
|
89
|
+
# first page.
|
83
90
|
if scope.page <= 1 && empty?
|
84
|
-
# This branch is an optimization: the call to the database to count is
|
85
|
-
# not necessary if we know that there are not even any results on the
|
86
|
-
# first page.
|
87
91
|
@current_page = 1
|
88
92
|
@total_count = 0
|
89
93
|
@total_pages = 1
|
90
94
|
@total_fast_count = 0
|
91
95
|
@total_fast_pages = 1
|
92
|
-
else
|
93
|
-
@pagination_scope = scope
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|
data/lib/simple/sql/version.rb
CHANGED