query_helper 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/query_helper.rb +9 -4
- data/lib/query_helper/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: d785c033c2c9b9f1eaa01641b8e92b8690a1a54eceb1507e58efb4a4437655ab
|
4
|
+
data.tar.gz: de0529d9069f0c612b39873c69160eff8eeb52b35bcc05401026cc161b9914c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39e7d8268cde0434747bfb2cc52e0f85c6d294ba18af86b5a415f5c92da2f1dfbe7822dbdc685c55f99520b15e205e2a75867db6e628b5d594730a1b472990ca
|
7
|
+
data.tar.gz: efcb54e2da3b21a3c454ff490b2c892336913dde41602aa07b31edf658f4644ebcc4f1a234bff8b72706ebd8fcfc7366de24c1a88891d1a3176d72686cdceb7e
|
data/Gemfile.lock
CHANGED
data/lib/query_helper.rb
CHANGED
@@ -13,7 +13,7 @@ require "query_helper/invalid_query_error"
|
|
13
13
|
|
14
14
|
class QueryHelper
|
15
15
|
|
16
|
-
attr_accessor :model, :bind_variables, :sql_filter, :sql_sort, :page, :per_page, :single_record, :associations, :as_json_options, :executed_query, :api_payload, :preload, :search_field, :search_string
|
16
|
+
attr_accessor :model, :bind_variables, :sql_filter, :sql_sort, :page, :per_page, :single_record, :associations, :as_json_options, :executed_query, :api_payload, :preload, :search_field, :search_string, :metadata
|
17
17
|
attr_reader :query
|
18
18
|
|
19
19
|
def initialize(
|
@@ -31,7 +31,8 @@ class QueryHelper
|
|
31
31
|
api_payload: false, # Return the paginated payload or simply return the result array
|
32
32
|
preload: [], # preload activerecord associations - used instead of `associations` when you don't want them included in the payload
|
33
33
|
search_fields: [],
|
34
|
-
search_string: nil
|
34
|
+
search_string: nil,
|
35
|
+
metadata: {}
|
35
36
|
)
|
36
37
|
@query = query.class < ActiveRecord::Relation ? query.to_sql : query
|
37
38
|
@model = query.class < ActiveRecord::Relation ? query.base_class : model
|
@@ -49,6 +50,7 @@ class QueryHelper
|
|
49
50
|
@preload = preload
|
50
51
|
@search_fields = search_fields
|
51
52
|
@search_string = search_string
|
53
|
+
@metadata = metadata
|
52
54
|
end
|
53
55
|
|
54
56
|
def update(
|
@@ -66,7 +68,8 @@ class QueryHelper
|
|
66
68
|
sql_sort: nil,
|
67
69
|
page: nil,
|
68
70
|
per_page: nil,
|
69
|
-
search_string: nil
|
71
|
+
search_string: nil,
|
72
|
+
metadata: nil
|
70
73
|
)
|
71
74
|
@query = query.class < ActiveRecord::Relation ? query.to_sql : query if query
|
72
75
|
@model = query.class < ActiveRecord::Relation ? query.base_class : model if model || query
|
@@ -83,6 +86,7 @@ class QueryHelper
|
|
83
86
|
@search_string = search_string if search_string
|
84
87
|
@page = determine_page(page: page, per_page: per_page) if page
|
85
88
|
@per_page = determine_per_page(page: page, per_page: per_page) if per_page
|
89
|
+
@metadata = metadata if metadata
|
86
90
|
set_limit_and_offset()
|
87
91
|
return self
|
88
92
|
end
|
@@ -203,7 +207,8 @@ class QueryHelper
|
|
203
207
|
|
204
208
|
def paginated_results
|
205
209
|
{ pagination: pagination_results(),
|
206
|
-
data: @results
|
210
|
+
data: @results,
|
211
|
+
metadata: @metadata }
|
207
212
|
end
|
208
213
|
|
209
214
|
def determine_count
|
data/lib/query_helper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: query_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan McDaniel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|