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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82a04d16c0467b1993e0624c59e2d77c2f7e7f7f
4
- data.tar.gz: 472e0c506b82a5fcee4c74f30b4de919f3d9946b
3
+ metadata.gz: fc6c2f2ade23b1396171f18642c26d30b8743d54
4
+ data.tar.gz: 255e9370843502bc5ca657c36dc57712a08b7905
5
5
  SHA512:
6
- metadata.gz: 6c66661d8d06232f9365f3f3683702ffe34be21424c090a92577c1794188ac03819fa227111ffd73424f35f58f48fa4e9d6b162a898d2984febc2893246114e3
7
- data.tar.gz: 2cd3cd6a3fe4cb95e7555c542d5a058ba6ffe803847313084751afc4b73622974632a1db7a91a8d525d7d4c3e4904350668f3879d831c9547640a9407cbcab7e
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
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Service
3
- VERSION = "0.0.81"
3
+ VERSION = "0.0.82"
4
4
  end
5
5
  end
@@ -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.81
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