ddc 0.1.0 → 0.1.1

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: beb0a92f622097983064f83fe5b0cb85a4e10361
4
- data.tar.gz: e1ae80d57029d1b62605d28313555e597138c7f9
3
+ metadata.gz: f4965b4c204f8f2294d07ab1565ff8c4438e5545
4
+ data.tar.gz: 700d22532820d534e1d0d0b1a296f26e836f4695
5
5
  SHA512:
6
- metadata.gz: d8af2e9a626edd66add56d57db5f196c8217eb22f8582894a7263ff435896b2a1477f365ae598853f50bc54f43052727da7da415e735c67d1e7d3c4045f4269c
7
- data.tar.gz: 0549ba0e5c2f500909b946a286ae511ada100f6a5d6d0f9d2098d472f81b3e1b574bde7c21d7c9eba3dcfbc11db173aed7e67882416a85b070afcec5ef26b4ac
6
+ metadata.gz: 498c59efdf922f09ae4b226444452a711f142b08b8308a605f28fdadcf62eb416efd7255ade2b6830550743ee10b5e5a737a4397eac1322edfecc04509fdb07c
7
+ data.tar.gz: 710fbeca96366bd9d0e38b057a13a1ea430e18cb6f892ad110d6a636f474f7c813d01e324c9dcc1308b4331139b7283525b815abaca603d1b75e3bb1b662e9ff
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # DDC Changelog
2
2
 
3
+ ### 0.1.1
4
+
5
+ * Fix update status code
6
+ * Add missing delete for generated services
7
+
3
8
  ### 0.1.0
4
9
 
5
10
  * API updates to be more consistent
@@ -6,7 +6,9 @@ module DDC
6
6
  created: 201,
7
7
  not_found: 404,
8
8
  not_allowed: 401,
9
- error: 500
9
+ error: 500,
10
+ not_valid: 422,
11
+ deleted: 204
10
12
  }
11
13
  class << self
12
14
  def build(controller_name, config)
@@ -3,11 +3,21 @@ module DDC
3
3
  def not_found
4
4
  {status: :not_found}
5
5
  end
6
+
6
7
  def ok(obj)
7
8
  {status: :ok, object: obj}
8
9
  end
10
+
9
11
  def created(obj)
10
12
  {status: :created, object: obj}
11
13
  end
14
+
15
+ def not_valid(obj)
16
+ {status: :not_valid, object: obj, errors: obj.errors.to_hash}
17
+ end
18
+
19
+ def deleted(obj)
20
+ {status: :deleted}
21
+ end
12
22
  end
13
23
  end
@@ -40,8 +40,12 @@ module DDC
40
40
  me = self.class.ar_model.where id: id
41
41
 
42
42
  if me.present?
43
- me.update_attributes translated_updates
44
- ok(me)
43
+ success = me.update_attributes translated_updates
44
+ if success
45
+ ok(me)
46
+ else
47
+ not_valid(me)
48
+ end
45
49
  else
46
50
  not_found
47
51
  end
@@ -50,7 +54,23 @@ module DDC
50
54
  def create(context)
51
55
  attributes = context.values_at self.class.model_type
52
56
  me = self.class.ar_model.create attributes
53
- created(me)
57
+ if me.persisted?
58
+ created(me)
59
+ else
60
+ not_valid(me)
61
+ end
62
+ end
63
+
64
+ def delete(context)
65
+ id = context[:id]
66
+ me = custom_finder ? custom_finder.find(context) :
67
+ ar_model.where(id: id)
68
+ if me.present?
69
+ me.destroy
70
+ deleted
71
+ else
72
+ not_found
73
+ end
54
74
  end
55
75
 
56
76
  private
data/lib/ddc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ddc
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-26 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -144,4 +144,3 @@ test_files:
144
144
  - spec/controller_builder_spec.rb
145
145
  - spec/service_builder_spec.rb
146
146
  - spec/spec_helper.rb
147
- has_rdoc: