pattern_query_helper 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/lib/pattern_query_helper.rb +6 -4
- data/lib/pattern_query_helper/associations.rb +3 -2
- data/lib/pattern_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: 9f0fe768952212e8b6a240fc7cee61e3dc768ae1aa41791c7e91761dbc2836c8
|
4
|
+
data.tar.gz: f2546fc691f1bdccca39f10fdabcbc2d419df7e9241a957986af9a2b0fe3bd4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
12
|
-
activesupport (= 5.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.
|
18
|
-
activesupport (= 5.2.
|
19
|
-
activerecord (5.2.
|
20
|
-
activemodel (= 5.2.
|
21
|
-
activesupport (= 5.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.
|
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.
|
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)
|
data/lib/pattern_query_helper.rb
CHANGED
@@ -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
|
-
|
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)
|
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.
|
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-
|
11
|
+
date: 2019-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|