acts_as_api 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ === 0.0.2 2010-01-01
2
+
3
+ * 1 major enhancement:
4
+ * Added a wrapping root node for JSON responses by default.
5
+
1
6
  === 0.0.1 2010-06-27
2
7
 
3
8
  * 1 major enhancement:
@@ -16,12 +16,17 @@ require "acts_as_api/array"
16
16
  # acts_as_api uses the default serializers of your rails app and doesn't
17
17
  # force you into more dependencies.
18
18
  module ActsAsApi
19
- VERSION = '0.0.1'
19
+ VERSION = '0.0.2'
20
20
 
21
21
  # The accepted response formats
22
22
  # Default is +[:xml, :json]+
23
23
  ACCEPTED_API_FORMATS = [:xml, :json]
24
24
 
25
+ # Holds references to formats that need
26
+ # to get added an additional root node
27
+ # with the name of the model.
28
+ ADD_ROOT_NODE_FOR = [:json]
29
+
25
30
  end
26
31
 
27
32
  # Attach ourselves to active record
@@ -29,10 +29,18 @@ module ActsAsApi
29
29
 
30
30
  # set the name of the root node - pluralize for arrays
31
31
  api_root_name = api_model.is_a?(Array) ? api_model.first.class.name.downcase.pluralize : api_model.class.name.downcase
32
+
32
33
  output_params[:root] = api_root_name
33
34
 
35
+ api_response = api_model.as_api_response
36
+
37
+ if ActsAsApi::ADD_ROOT_NODE_FOR.include? api_format
38
+ api_response = { api_root_name.to_sym => api_response}
39
+ end
40
+
41
+
34
42
  # create the Hash as response
35
- output_params[api_format] = api_model.as_api_response
43
+ output_params[api_format] = as_api_response
36
44
 
37
45
  render output_params
38
46
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Christian B\xC3\xA4uerlein"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-30 00:00:00 +02:00
17
+ date: 2010-07-01 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency