model_driven_api 3.9.0 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0955834f57dc25b51a326caf3a64d2da728c635eacb2b01cf1e9f656e559ea5
4
- data.tar.gz: 677af97d19ed54c6cba486f0d99bce4736e4e06e3f916c4d0c896a13eef8c865
3
+ metadata.gz: 2814cf6ff3fc8c2b60cb3b663aa0860d25161c8cd0971a6b76f3efd0b29df966
4
+ data.tar.gz: 519245af607dff7b04652b65efb88584dc6559f6cc21a60a5591e7c081a9a00d
5
5
  SHA512:
6
- metadata.gz: 07f3a5338e772e90baf5687dc38b6b038b55b97da94bae909d544408767b67927da667507f3e84e52a80f4cc7ff26c275757d9700f1bbfb0ce8914784da206fd
7
- data.tar.gz: ec926ebae3447ad6ba9f8231dd60b2992f75b2838b2b49be14378390fe63f99b0af3085f9759ea0e2d580477463fa10d092b651dc29452597f0801c420b4eb18
6
+ metadata.gz: d15e193b9f21739e577dbc8243e4bb44ff127fa048d4cef33551b58ee55349f27ccd1ca99ac16044c2eed5f844924389542df276f1d7ba06e89d294af5deb164
7
+ data.tar.gz: 889853a5ce035794316072a74515842f4a43d41a056523de35993bccf270b51475ac195d5b2b96f08db5b1f6829ab47936616a9e162c7bac682b988ee641a6a5
@@ -112,7 +112,9 @@ class Api::V2::ApplicationController < ActionController::API
112
112
  return render json: result, status: (status_number.presence || 200) if status == true
113
113
 
114
114
  # Normal Destroy Action
115
- return api_error(status: 500) unless @record.destroy
115
+ # A validation/before_destroy guard (e.g. dependent: :restrict_with_error) blocking this
116
+ # destroy populates @record.errors — surface it as a 422, not a bodyless 500.
117
+ return api_error(status: 422, errors: @record.errors) unless @record.destroy
116
118
  head :ok
117
119
  end
118
120
 
@@ -9,6 +9,10 @@ module ApiExceptionManagement
9
9
  rescue_from ActionController::RoutingError, with: :not_found!
10
10
  rescue_from ActiveModel::ForbiddenAttributesError, with: :fivehundred!
11
11
  rescue_from ActiveRecord::RecordInvalid, with: :invalid!
12
+ # A destroy blocked by dependent: :restrict_with_error or a before_destroy guard
13
+ # (e.g. Task's time_tables-present guard, docs/adr/0010, host repo) raises this via
14
+ # #destroy! — reuse invalid! since both exceptions expose the same .record interface.
15
+ rescue_from ActiveRecord::RecordNotDestroyed, with: :invalid!
12
16
  rescue_from ActiveRecord::RecordNotFound, with: :not_found!
13
17
  rescue_from ActiveRecord::RecordNotUnique, with: :invalid!
14
18
  # Rescue Stale Object in Optimistick locking with stale!
@@ -1,3 +1,3 @@
1
1
  module ModelDrivenApi
2
- VERSION = "3.9.0".freeze
2
+ VERSION = "3.10.0".freeze
3
3
  end
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/class/attribute_accessors"
2
+
1
3
  class NonCrudEndpoints
2
4
  attr_accessor :result
3
5
  cattr_accessor :definitions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_driven_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni