fetcha 0.2.1 → 0.2.2
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/fetcha.rb +23 -3
- data/lib/fetcha/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61d61933364bc8cb1c81431a9c5ba0fc4224c670
|
4
|
+
data.tar.gz: 422b38441617e39ed53166ff55f87578539dbacd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f931681d3c2bab0b4609c07f6f1abdee6ef15c62f4e31ca2a0afe8dd4aa4192eca694fa087fe68761c37916a4ce058465bcf2c6a3cae77428db01c2cbb3ad58c
|
7
|
+
data.tar.gz: 47f49b64deb5b1c414c5673151a199df55ae2f69371ef885a099ab58d71aa3893bf7480efc019216f5262d145abaa8ac5b7e93e444414e5c437977a148ce8092
|
data/lib/fetcha.rb
CHANGED
@@ -18,7 +18,28 @@ module Fetcha
|
|
18
18
|
results = process_sorting(results, sorting) if sorting
|
19
19
|
results = process_pagination!(results, pages) if pages
|
20
20
|
results = process_search(results, search) if search
|
21
|
-
results
|
21
|
+
results.extending(PaginationTotalCount)
|
22
|
+
end
|
23
|
+
|
24
|
+
module PaginationTotalCount
|
25
|
+
def reset
|
26
|
+
@total_count = nil
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def total_count(column_name = :all, _options = nil)
|
31
|
+
@total_count ||=
|
32
|
+
begin
|
33
|
+
c = except(:offset, :limit, :order)
|
34
|
+
c = c.count(column_name)
|
35
|
+
|
36
|
+
if c.is_a?(Hash) || c.is_a?(ActiveSupport::OrderedHash)
|
37
|
+
c.count
|
38
|
+
else
|
39
|
+
c.respond_to?(:count) ? c.count(column_name) : c
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
22
43
|
end
|
23
44
|
|
24
45
|
private
|
@@ -63,8 +84,7 @@ module Fetcha
|
|
63
84
|
end
|
64
85
|
|
65
86
|
def process_scope(datasource, query_scope)
|
66
|
-
|
67
|
-
datasource.send(query_scope)
|
87
|
+
datasource.send(query_scope) if (fetchable_opts[:scopes].include? query_scope.to_sym)
|
68
88
|
end
|
69
89
|
|
70
90
|
def process_search(datasource, search)
|
data/lib/fetcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fetcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincenzo Ferrara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.6
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Enable api to respond to jsonapi query string
|