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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0ce7906e41c5c383352f7c5cab44a96a1cfac4101f70a29baf72275151d91b4
4
- data.tar.gz: 8add1223d5c3da00ceb82af7125f01175e3072057ae7d29368d1cc5f12ba1854
3
+ metadata.gz: d785c033c2c9b9f1eaa01641b8e92b8690a1a54eceb1507e58efb4a4437655ab
4
+ data.tar.gz: de0529d9069f0c612b39873c69160eff8eeb52b35bcc05401026cc161b9914c9
5
5
  SHA512:
6
- metadata.gz: a81a407516f330e80191f1d2d41be5c091aede40b3950503ff05eeda26a2e09fefb6be3dd03a3280765b53f0b6da9c3c64c963bc84a0788be6d9af9d3aa088be
7
- data.tar.gz: 91ba599cff34800fb1c0e7cb39d0a07e51b4320ff5e7d8248f9c2abf97794532db6a6fbc29f397dca620e363d75cbe883ae72ca983010510a17c4105ecfb5f42
6
+ metadata.gz: 39e7d8268cde0434747bfb2cc52e0f85c6d294ba18af86b5a415f5c92da2f1dfbe7822dbdc685c55f99520b15e205e2a75867db6e628b5d594730a1b472990ca
7
+ data.tar.gz: efcb54e2da3b21a3c454ff490b2c892336913dde41602aa07b31edf658f4644ebcc4f1a234bff8b72706ebd8fcfc7366de24c1a88891d1a3176d72686cdceb7e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- query_helper (0.2.11)
4
+ query_helper (0.2.12)
5
5
  activerecord (> 5)
6
6
  activesupport (> 5)
7
7
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  class QueryHelper
2
- VERSION = "0.2.11"
2
+ VERSION = "0.2.12"
3
3
  end
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.11
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-05-04 00:00:00.000000000 Z
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler