pattern_query_helper 0.2.3 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38dc301a4cb672d6462a7e7b94284493b46718ed016f68c0c3282a9233abf2fc
4
- data.tar.gz: f41c477445fcdda1d57e8e76b40cac7c9acc9f88da328d82040c7ecdad062e08
3
+ metadata.gz: 9f0fe768952212e8b6a240fc7cee61e3dc768ae1aa41791c7e91761dbc2836c8
4
+ data.tar.gz: f2546fc691f1bdccca39f10fdabcbc2d419df7e9241a957986af9a2b0fe3bd4a
5
5
  SHA512:
6
- metadata.gz: 2dd92c57a1dcab50677649498fde26983f685899e10f096bbce573544420ae0c3c7736b22836d1e8c8ccd6450a7f33c6ebce5f1b03f69eb2b41fca9357a13eb0
7
- data.tar.gz: 5a062958f9d86f8264fa86b5914a7f958940a39c743d9d8f62dd4f2c4ee4db14d26543436075400d04e2c33e1cf858cc6723f59083d736ab1a892d2b41a6d931
6
+ metadata.gz: 1d9b94902b4ffc1ed5201c25edc7f34717ad01f575202692f48e111a692f208ed1efe88e289510577659090729d380f69537766f7193df6854f369950270be46
7
+ data.tar.gz: 483a160eaaac70209bfbde5642b55516a1bb50ba36566fa0b1bfa85f792ad7795962f5c667c5bf3325b284f8c624296f4ce648950d8cef76cd3145c6f1e1f80e
data/Gemfile.lock CHANGED
@@ -1,26 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pattern_query_helper (0.2.3)
4
+ pattern_query_helper (0.2.4)
5
5
  activerecord (~> 5.0)
6
6
  kaminari (~> 1.1.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionview (5.2.2)
12
- activesupport (= 5.2.2)
11
+ actionview (5.2.3)
12
+ activesupport (= 5.2.3)
13
13
  builder (~> 3.1)
14
14
  erubi (~> 1.4)
15
15
  rails-dom-testing (~> 2.0)
16
16
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
17
- activemodel (5.2.2)
18
- activesupport (= 5.2.2)
19
- activerecord (5.2.2)
20
- activemodel (= 5.2.2)
21
- activesupport (= 5.2.2)
17
+ activemodel (5.2.3)
18
+ activesupport (= 5.2.3)
19
+ activerecord (5.2.3)
20
+ activemodel (= 5.2.3)
21
+ activesupport (= 5.2.3)
22
22
  arel (>= 9.0)
23
- activesupport (5.2.2)
23
+ activesupport (5.2.3)
24
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
25
  i18n (>= 0.7, < 2)
26
26
  minitest (~> 5.1)
@@ -53,7 +53,7 @@ GEM
53
53
  nokogiri (>= 1.5.9)
54
54
  mini_portile2 (2.4.0)
55
55
  minitest (5.11.3)
56
- nokogiri (1.10.1)
56
+ nokogiri (1.10.2)
57
57
  mini_portile2 (~> 2.4.0)
58
58
  rails-dom-testing (2.0.3)
59
59
  activesupport (>= 4.2.0)
@@ -38,7 +38,7 @@ module PatternQueryHelper
38
38
  }
39
39
 
40
40
  data = PatternQueryHelper::Sql.sql_query(query_config)
41
- data = PatternQueryHelper::Associations.load_associations(data, query_helpers[:associations])
41
+ data = PatternQueryHelper::Associations.load_associations(data, query_helpers[:associations], query_helpers[:as_json])
42
42
  count = PatternQueryHelper::Sql.sql_query_count(query_config)
43
43
  pagination = PatternQueryHelper::Pagination.create_pagination_payload(count, query_helpers[:pagination])
44
44
 
@@ -61,7 +61,7 @@ module PatternQueryHelper
61
61
  }
62
62
 
63
63
  data = PatternQueryHelper::Sql.sql_query(query_config)
64
- data = PatternQueryHelper::Associations.load_associations(data, query_helpers[:associations])
64
+ data = PatternQueryHelper::Associations.load_associations(data, query_helpers[:associations], query_helpers[:as_json])
65
65
 
66
66
  {
67
67
  data: data
@@ -81,7 +81,7 @@ module PatternQueryHelper
81
81
  }
82
82
 
83
83
  data = PatternQueryHelper::Sql.single_record_query(query_config)
84
- data = PatternQueryHelper::Associations.load_associations(data, query_helpers[:associations])
84
+ data = PatternQueryHelper::Associations.load_associations(data, query_helpers[:associations], query_helpers[:as_json])
85
85
 
86
86
  {
87
87
  data: data
@@ -97,12 +97,14 @@ module PatternQueryHelper
97
97
  sorting = PatternQueryHelper::Sorting.parse_sorting_params(query_helpers[:sort], valid_columns)
98
98
  associations = PatternQueryHelper::Associations.process_association_params(query_helpers[:include])
99
99
  pagination = PatternQueryHelper::Pagination.parse_pagination_params(query_helpers[:page], query_helpers[:per_page])
100
+ as_json = query_helpers[:as_json]
100
101
 
101
102
  {
102
103
  filters: filtering,
103
104
  sorting: sorting,
104
105
  associations: associations,
105
- pagination: pagination
106
+ pagination: pagination,
107
+ as_json: as_json
106
108
  }
107
109
  end
108
110
 
@@ -9,9 +9,10 @@ module PatternQueryHelper
9
9
  end
10
10
  end
11
11
 
12
- def self.load_associations(payload, associations)
12
+ def self.load_associations(payload, associations, as_json_options)
13
13
  ActiveRecord::Associations::Preloader.new.preload(payload, associations)
14
- payload.as_json(include: json_associations(associations))
14
+ as_json_options ||= { include: json_associations(associations) }
15
+ payload.as_json(as_json_options)
15
16
  end
16
17
 
17
18
  def self.json_associations(associations)
@@ -1,3 +1,3 @@
1
1
  module PatternQueryHelper
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pattern_query_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan McDaniel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-02 00:00:00.000000000 Z
11
+ date: 2019-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler