apicasso 0.2.9 → 0.2.10

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: 922eed4373921e41ed9970b3bc152e219d2e5c17
4
- data.tar.gz: 187957d76051bf9d5e6fa0d5a888ee650d30f2d6
3
+ metadata.gz: 16f579b7e6f224222ad10d35efc087d99c2ff04e
4
+ data.tar.gz: b31b8cf77845d01fd00885c1a4f516f2d582d902
5
5
  SHA512:
6
- metadata.gz: acc0fc2db3b22cc91ddbe1bf39f44ade021dc62eeed818050dd744d942ff38f8cff17e6b0c32c8d8937798b62e9ca47906b0a5b35f4f81bb18927c9e2ef1b4da
7
- data.tar.gz: 7a0dae9df3e370456278d3b04845253cfa5bd598c18a4ae9abc84c0ad619b15f21cd499245fd41da4e1bcaf3d43efbb0223a7d542d907dccc0721d9b79f9d6e1
6
+ metadata.gz: 6722df9eca40fb953717fbe36039f810b76b0d11c16c71002fa7533243aa7f8d1e14f4e3526c5f8d23d2c09e16ca254b6c1935540298d1b2acc7ac816f054215
7
+ data.tar.gz: f5c6f9d92296e40ef83207552f489a47e25805ae03016e1e79da3e8ffb0475a225fa2fbd95873c1035ead75884f2ebfc4ce06efaaa5d202f1891e47358ea7637
@@ -47,7 +47,7 @@ module Apicasso
47
47
  def response_hash
48
48
  {
49
49
  status: response.status,
50
- body: (response.body.present? ? JSON.parse(response.body): '')
50
+ body: (response.body.present? ? JSON.parse(response.body) : '')
51
51
  }
52
52
  end
53
53
 
@@ -24,12 +24,15 @@ module Apicasso
24
24
  end
25
25
 
26
26
  # GET /:resource/1
27
+ # Common behavior for showing a record, with an addition of
28
+ # relation/methods including on response
27
29
  def show
28
30
  set_access_control_headers
29
31
  render json: @object.to_json(include: parsed_include)
30
32
  end
31
33
 
32
34
  # PATCH/PUT /:resource/1
35
+ # Common behavior for an update API endpoint
33
36
  def update
34
37
  authorize_for(action: :update,
35
38
  resource: resource.name.underscore.to_sym,
@@ -42,12 +45,13 @@ module Apicasso
42
45
  end
43
46
 
44
47
  # DELETE /:resource/1
48
+ # Common behavior for an destroy API endpoint
45
49
  def destroy
46
50
  authorize_for(action: :destroy,
47
51
  resource: resource.name.underscore.to_sym,
48
52
  object: @object)
49
53
  if @object.destroy
50
- head :no_content
54
+ head :no_content, status: :ok
51
55
  else
52
56
  render json: @object.errors, status: :unprocessable_entity
53
57
  end
@@ -157,7 +161,7 @@ module Apicasso
157
161
 
158
162
  # Parsing of `paginated_records` with pagination variables metadata
159
163
  def built_paginated
160
- { entries: @records }.merge(pagination_metadata_for(paginated_records))
164
+ { entries: paginated_records }.merge(pagination_metadata_for(paginated_records))
161
165
  end
162
166
 
163
167
  # All records matching current query and it's total
@@ -170,6 +174,7 @@ module Apicasso
170
174
  @records = JSON.parse(included_collection.to_json(include: parsed_include))
171
175
  end
172
176
 
177
+ # A way to SQL-include if available for current param[:include]
173
178
  def included_collection
174
179
  if @records.try(:includes, parsed_include).present?
175
180
  @records.includes(parsed_include)
@@ -1,3 +1,3 @@
1
1
  module Apicasso
2
- VERSION = '0.2.9'
2
+ VERSION = '0.2.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apicasso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Bellincanta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-03 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cancancan