deep_unrest 0.1.72 → 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 +5 -27
- data/lib/deep_unrest/version.rb +1 -1
- data/lib/deep_unrest/write.rb +3 -2
- 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,36 +116,22 @@ module DeepUnrest
|
|
116
116
|
paginator = get_paginator(query, parent)
|
117
117
|
resource = item[:resource]
|
118
118
|
|
119
|
-
|
120
|
-
if r_metaclass.method_defined? :records
|
121
|
-
r_metaclass.class_eval do
|
122
|
-
alias_method :records_original, :records
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
# TODO: find a way to do this that doesn't blow out the original :records method
|
127
|
-
resource.define_singleton_method(:records) { |ctx|
|
128
|
-
full_scope = if self.respond_to? :records_original
|
129
|
-
records_original(ctx)
|
130
|
-
else
|
131
|
-
super(ctx)
|
132
|
-
end
|
133
|
-
|
134
|
-
item[:scope].merge(full_scope)
|
135
|
-
}
|
119
|
+
resource_scope = item[:scope]
|
136
120
|
|
137
121
|
# transform sort value casing for rails
|
138
122
|
sort_criteria = query[:sort]&.map { |s| s.clone.merge(field: s[:field].underscore) }
|
139
123
|
serializer = JSONAPI::ResourceSerializer.new(resource)
|
124
|
+
|
140
125
|
processor = JSONAPI::Processor.new(resource,
|
141
126
|
:find,
|
142
127
|
filters: query[:filter] || {},
|
143
|
-
context: ctx,
|
128
|
+
context: ctx.clone.merge(scope: resource_scope),
|
144
129
|
sort_criteria: sort_criteria,
|
145
130
|
serializer: serializer,
|
146
131
|
paginator: paginator)
|
147
132
|
|
148
133
|
jsonapi_result = processor.process
|
134
|
+
|
149
135
|
resource_results = format_processor_results(resource, jsonapi_result)
|
150
136
|
|
151
137
|
meta << {
|
@@ -178,15 +164,6 @@ module DeepUnrest
|
|
178
164
|
included << result
|
179
165
|
recurse_included_queries(ctx, result, mappings, parent_context, included, meta, [*next_addr, :include])
|
180
166
|
end
|
181
|
-
ensure
|
182
|
-
# un-monkey patch the resource :records method
|
183
|
-
if r_metaclass.method_defined? :records_original
|
184
|
-
r_metaclass.class_eval do
|
185
|
-
alias_method :records, :records_original
|
186
|
-
end
|
187
|
-
else
|
188
|
-
r_metaclass.undef_method :records
|
189
|
-
end
|
190
167
|
end
|
191
168
|
|
192
169
|
def self.get_query_type(item)
|
@@ -239,3 +216,4 @@ module DeepUnrest
|
|
239
216
|
end
|
240
217
|
end
|
241
218
|
end
|
219
|
+
|
data/lib/deep_unrest/version.rb
CHANGED
data/lib/deep_unrest/write.rb
CHANGED
@@ -110,7 +110,7 @@ module DeepUnrest
|
|
110
110
|
update_body[:_destroy] = true if item.dig(:query, :destroy)
|
111
111
|
DeepUnrest.set_attr(memo, item[:ar_addr].clone, update_body)
|
112
112
|
if item[:ar_addr].size == 1
|
113
|
-
item[:mutate] =
|
113
|
+
item[:mutate] = update_body
|
114
114
|
item[:scope_type] = :update if item[:scope_type] == :show
|
115
115
|
end
|
116
116
|
end
|
@@ -142,9 +142,10 @@ module DeepUnrest
|
|
142
142
|
when :destroy
|
143
143
|
id = item.dig(:query, :id)
|
144
144
|
model = item[:klass].find(id)
|
145
|
+
model.deep_unrest_query_uuid = item.dig(:query, :uuid)
|
145
146
|
resource = item[:resource].new(model, context)
|
146
147
|
resource.run_callbacks :remove do
|
147
|
-
|
148
|
+
model.destroy!
|
148
149
|
end
|
149
150
|
end
|
150
151
|
|
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-
|
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
|