api_me 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api_me.rb +9 -9
- data/lib/api_me/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed39f052b8ffaff2339bce75592a4ba2ee371c451e496411333e3b472711be9d
|
4
|
+
data.tar.gz: d24e777c24e9df8348937da77af6251f1e5a03e85e080cf48639a0e7a2ed0e1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fef805b6c67b1d45e623e95386cda60de7ec62dd71cfb5590b4f7bd3c00b65e9ece521686e7c2a18d03eeb42fc0b91ae61b0e3c49fc7e69951d75b404142a95
|
7
|
+
data.tar.gz: 60ace944bf79b1c168c32f471335f72a997b8bf3c868e2198a45a3cadbc8080eb2a85de09624e29d2edb97736f18c97b022adc7bf7537be476a80652a18be6dc
|
data/lib/api_me.rb
CHANGED
@@ -95,7 +95,7 @@ module ApiMe
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def new
|
98
|
-
render_errors(['new endpoint not supported'],
|
98
|
+
render_errors(['new endpoint not supported'], :not_found)
|
99
99
|
end
|
100
100
|
|
101
101
|
def create
|
@@ -103,11 +103,11 @@ module ApiMe
|
|
103
103
|
authorize_resource @object
|
104
104
|
create_resource!
|
105
105
|
|
106
|
-
render status:
|
106
|
+
render status: :created, json: @object, root: singular_root_key, serializer: serializer_klass
|
107
107
|
end
|
108
108
|
|
109
109
|
def edit
|
110
|
-
render_errors(['edit endpoint not supported'],
|
110
|
+
render_errors(['edit endpoint not supported'], :not_found)
|
111
111
|
end
|
112
112
|
|
113
113
|
def update
|
@@ -116,7 +116,7 @@ module ApiMe
|
|
116
116
|
authorize_resource @object
|
117
117
|
update_resource!
|
118
118
|
|
119
|
-
|
119
|
+
render status: :ok, json: @object, root: singular_root_key, serializer: serializer_klass
|
120
120
|
end
|
121
121
|
|
122
122
|
def destroy
|
@@ -124,7 +124,7 @@ module ApiMe
|
|
124
124
|
authorize_resource @object
|
125
125
|
destroy_resource!
|
126
126
|
|
127
|
-
head
|
127
|
+
head :no_content
|
128
128
|
end
|
129
129
|
|
130
130
|
protected
|
@@ -149,7 +149,7 @@ module ApiMe
|
|
149
149
|
params[:sort]
|
150
150
|
end
|
151
151
|
|
152
|
-
def render_errors(errors, status =
|
152
|
+
def render_errors(errors, status = :unprocessable_entity)
|
153
153
|
render(json: { errors: errors }, status: status)
|
154
154
|
end
|
155
155
|
|
@@ -161,11 +161,11 @@ module ApiMe
|
|
161
161
|
|
162
162
|
def user_not_authorized
|
163
163
|
payload = { message: "User is not allowed to access #{params[:action]} on this resource" }
|
164
|
-
render json: payload, status:
|
164
|
+
render json: payload, status: :forbidden
|
165
165
|
end
|
166
166
|
|
167
167
|
def resource_not_found
|
168
|
-
head
|
168
|
+
head :not_found
|
169
169
|
end
|
170
170
|
|
171
171
|
def model_klass
|
@@ -227,7 +227,7 @@ module ApiMe
|
|
227
227
|
end
|
228
228
|
|
229
229
|
def find_resource
|
230
|
-
@find_resource ||= model_klass.
|
230
|
+
@find_resource ||= model_klass.find_by!(id: params[:id])
|
231
231
|
end
|
232
232
|
|
233
233
|
def build_resource
|
data/lib/api_me/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Clopton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-01-
|
12
|
+
date: 2020-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|