restpack_service 0.0.81 → 0.0.82
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restpack_service/commands/update.rb +37 -0
- data/lib/restpack_service/version.rb +1 -1
- data/lib/restpack_service.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc6c2f2ade23b1396171f18642c26d30b8743d54
|
4
|
+
data.tar.gz: 255e9370843502bc5ca657c36dc57712a08b7905
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 038bea4b32821715071d5e0c7f4d70fd6bf7e6297d2a50ec6f72e5283ec5f52b25bbc5088a6a82b091af939a96e3f88b1d8597b5672918761526af7d4e16b85a
|
7
|
+
data.tar.gz: bef31256365b03b3298a6da500f86ce8adc7a2a7abe0c651c3aa982b8c92c25c0495bae4c9dce6254d55cc45228224cc3584d456b9cfca11b07ca365e0f4d52b
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RestPack::Service
|
2
|
+
module Commands
|
3
|
+
class Update < RestPack::Service::Command
|
4
|
+
|
5
|
+
def execute
|
6
|
+
key = self.class.serializer_class.key
|
7
|
+
result = { key => [] }
|
8
|
+
|
9
|
+
self.class.model_class.transaction do
|
10
|
+
inputs[key].each do |model_inputs|
|
11
|
+
model = find_model(model_inputs)
|
12
|
+
|
13
|
+
if model
|
14
|
+
model = update_model(model, model_inputs)
|
15
|
+
result[key] << self.class.serializer_class.as_json(model)
|
16
|
+
else
|
17
|
+
status :not_found
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def find_model(model_inputs)
|
28
|
+
self.class.model_class.find(model_inputs[:id])
|
29
|
+
end
|
30
|
+
|
31
|
+
def update_model(model, model_inputs)
|
32
|
+
model.update_attributes(model_inputs)
|
33
|
+
model
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/restpack_service.rb
CHANGED
@@ -13,5 +13,6 @@ require "restpack_service/commands/get"
|
|
13
13
|
require "restpack_service/commands/create"
|
14
14
|
require "restpack_service/commands/single_create"
|
15
15
|
require "restpack_service/commands/list"
|
16
|
+
require "restpack_service/commands/update"
|
16
17
|
|
17
18
|
require "restpack_service/loader"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.82
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
@@ -227,6 +227,7 @@ files:
|
|
227
227
|
- lib/restpack_service/commands/get.rb
|
228
228
|
- lib/restpack_service/commands/list.rb
|
229
229
|
- lib/restpack_service/commands/single_create.rb
|
230
|
+
- lib/restpack_service/commands/update.rb
|
230
231
|
- lib/restpack_service/configuration.rb
|
231
232
|
- lib/restpack_service/loader.rb
|
232
233
|
- lib/restpack_service/response.rb
|