model_driven_api 2.4.4 → 2.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/application_controller.rb +13 -12
- 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: 1ed6351d23e6db1dca7d4fffe1ac0e532d12492c404cdf37763afd644fc5cca5
|
4
|
+
data.tar.gz: 3003182226f97c82f510c5b5e3b38a78cd851eab30378035cb939afdc94a863c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56ab41d307daf87674df375320d361d525bb941367dd7be9f95b3f9f0568f4ff91b243215720ba1e13fcb46130ce6dd2a60b780ca50700c97ec92ed87d0d6e8a
|
7
|
+
data.tar.gz: 2d4cbb4267a876d13ddd5f18a6bf89a794afccdb0cbc418c4080a5adf3716a80e9a9346529a80f0f18b78e9623cf1b0c3e06db5c2b61069c4618b8ace6cdab96
|
@@ -16,8 +16,8 @@ class Api::V2::ApplicationController < ActionController::API
|
|
16
16
|
authorize! :index, @model
|
17
17
|
|
18
18
|
# Custom Action
|
19
|
-
status, result = check_for_custom_action
|
20
|
-
return render json: result, status: 200 if status == true
|
19
|
+
status, result, status_number = check_for_custom_action
|
20
|
+
return render json: result, status: (status_number.presence || 200) if status == true
|
21
21
|
|
22
22
|
# Normal Index Action with Ransack querying
|
23
23
|
# Keeping this automation can be too dangerous and lead to unpredicted results
|
@@ -52,8 +52,8 @@ class Api::V2::ApplicationController < ActionController::API
|
|
52
52
|
authorize! :show, @record_id
|
53
53
|
|
54
54
|
# Custom Show Action
|
55
|
-
status, result = check_for_custom_action
|
56
|
-
return render json: result, status: 200 if status == true
|
55
|
+
status, result, status_number = check_for_custom_action
|
56
|
+
return render json: result, status: (status_number.presence || 200) if status == true
|
57
57
|
|
58
58
|
# Normal Show
|
59
59
|
result = @record.to_json(json_attrs)
|
@@ -65,8 +65,8 @@ class Api::V2::ApplicationController < ActionController::API
|
|
65
65
|
authorize! :create, @record
|
66
66
|
|
67
67
|
# Custom Action
|
68
|
-
status, result = check_for_custom_action
|
69
|
-
return render json: result, status: 200 if status == true
|
68
|
+
status, result, status_number = check_for_custom_action
|
69
|
+
return render json: result, status: (status_number.presence || 200) if status == true
|
70
70
|
|
71
71
|
# Normal Create Action
|
72
72
|
# Keeping this automation can be too dangerous and lead to unpredicted results
|
@@ -80,8 +80,8 @@ class Api::V2::ApplicationController < ActionController::API
|
|
80
80
|
authorize! :update, @record
|
81
81
|
|
82
82
|
# Custom Action
|
83
|
-
status, result = check_for_custom_action
|
84
|
-
return render json: result, status: 200 if status == true
|
83
|
+
status, result, status_number = check_for_custom_action
|
84
|
+
return render json: result, status: (status_number.presence || 200) if status == true
|
85
85
|
|
86
86
|
# Normal Update Action
|
87
87
|
# Raisl 6 vs Rails 6.1
|
@@ -93,8 +93,8 @@ class Api::V2::ApplicationController < ActionController::API
|
|
93
93
|
authorize! :destroy, @record
|
94
94
|
|
95
95
|
# Custom Action
|
96
|
-
status, result = check_for_custom_action
|
97
|
-
return render json: result, status: 200 if status == true
|
96
|
+
status, result, status_number = check_for_custom_action
|
97
|
+
return render json: result, status: (status_number.presence || 200) if status == true
|
98
98
|
|
99
99
|
# Normal Destroy Action
|
100
100
|
return api_error(status: 500) unless @record.destroy
|
@@ -114,8 +114,9 @@ class Api::V2::ApplicationController < ActionController::API
|
|
114
114
|
resource = "custom_action_#{params[:do]}"
|
115
115
|
raise NoMethodError unless @model.respond_to?(resource)
|
116
116
|
# return true, MultiJson.dump(params[:id].blank? ? @model.send(resource, params) : @model.send(resource, params[:id].to_i, params))
|
117
|
-
puts json_attrs
|
118
|
-
|
117
|
+
# puts json_attrs
|
118
|
+
body, status = @model.send(resource, params)
|
119
|
+
return true, body.to_json(json_attrs), status
|
119
120
|
end
|
120
121
|
# if it's here there is no custom action in the request querystring
|
121
122
|
return false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_driven_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thecore_backend_commons
|