deep_unrest 0.1.75 → 0.1.76
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/deep_unrest/concerns/resource_scope.rb +13 -0
- data/lib/deep_unrest/engine.rb +1 -0
- data/lib/deep_unrest/read.rb +3 -10
- data/lib/deep_unrest/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5414c5023858644639737c10519236d5d27d7d5f645a65c1a47f784b5c0f1cdc
|
4
|
+
data.tar.gz: e36e32772f0e662881f2d29acbbff47634d6f8cb2f214394a52aa72937a43262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afd8b1351ecfc59ae5c4ce9834cdabe02ad3fd4cf89b9e9c955b92512d2a12ca7f1b0a779b649cdc3cc538a8711d8e8071d5199a383ac7f9e11806c9add4e4fe
|
7
|
+
data.tar.gz: 5cc341b7eb963ad418a813087c44a24d28aef45548babc7bd35f1f150fba14dc6b804fd501cfc533c950ae7d143224de0422546414241751880b68bc542e8968
|
data/lib/deep_unrest/engine.rb
CHANGED
@@ -4,6 +4,7 @@ require 'deep_unrest/authorization/pundit_strategy'
|
|
4
4
|
require 'deep_unrest/paginators/basic'
|
5
5
|
require 'deep_unrest/concerns/null_concern'
|
6
6
|
require 'deep_unrest/concerns/map_temp_ids'
|
7
|
+
require 'deep_unrest/concerns/resource_scope'
|
7
8
|
|
8
9
|
module DeepUnrest
|
9
10
|
class Engine < ::Rails::Engine
|
data/lib/deep_unrest/read.rb
CHANGED
@@ -116,9 +116,7 @@ module DeepUnrest
|
|
116
116
|
paginator = get_paginator(query, parent)
|
117
117
|
resource = item[:resource]
|
118
118
|
|
119
|
-
|
120
|
-
old_records = resource.method(:records)
|
121
|
-
resource.define_singleton_method(:records) { |ctx| item[:scope].merge(old_records.call(ctx)) }
|
119
|
+
resource_scope = item[:scope]
|
122
120
|
|
123
121
|
# transform sort value casing for rails
|
124
122
|
sort_criteria = query[:sort]&.map { |s| s.clone.merge(field: s[:field].underscore) }
|
@@ -127,7 +125,7 @@ module DeepUnrest
|
|
127
125
|
processor = JSONAPI::Processor.new(resource,
|
128
126
|
:find,
|
129
127
|
filters: query[:filter] || {},
|
130
|
-
context: ctx,
|
128
|
+
context: ctx.clone.merge(scope: resource_scope),
|
131
129
|
sort_criteria: sort_criteria,
|
132
130
|
serializer: serializer,
|
133
131
|
paginator: paginator)
|
@@ -136,9 +134,6 @@ module DeepUnrest
|
|
136
134
|
|
137
135
|
resource_results = format_processor_results(resource, jsonapi_result)
|
138
136
|
|
139
|
-
# un-monkey patch the resource :records method
|
140
|
-
resource.define_singleton_method(:records, old_records)
|
141
|
-
|
142
137
|
meta << {
|
143
138
|
addr: [*addr, item[:key], 'meta'],
|
144
139
|
serialized_result: {
|
@@ -169,9 +164,6 @@ module DeepUnrest
|
|
169
164
|
included << result
|
170
165
|
recurse_included_queries(ctx, result, mappings, parent_context, included, meta, [*next_addr, :include])
|
171
166
|
end
|
172
|
-
rescue StandardError => e
|
173
|
-
# un-monkey patch the resource :records method
|
174
|
-
resource.define_singleton_method(:records, old_records)
|
175
167
|
end
|
176
168
|
|
177
169
|
def self.get_query_type(item)
|
@@ -224,3 +216,4 @@ module DeepUnrest
|
|
224
216
|
end
|
225
217
|
end
|
226
218
|
end
|
219
|
+
|
data/lib/deep_unrest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_unrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.76
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lynn Hurley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/deep_unrest/authorization/pundit_strategy.rb
|
148
148
|
- lib/deep_unrest/concerns/map_temp_ids.rb
|
149
149
|
- lib/deep_unrest/concerns/null_concern.rb
|
150
|
+
- lib/deep_unrest/concerns/resource_scope.rb
|
150
151
|
- lib/deep_unrest/engine.rb
|
151
152
|
- lib/deep_unrest/paginators/basic.rb
|
152
153
|
- lib/deep_unrest/read.rb
|