model_driven_api 3.5.2 → 3.5.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5dfed0ca77401f9f18a60d58a3477f3448dff4cf5d6267bb6adf4e3ef87325
|
4
|
+
data.tar.gz: d1e83dcc5916b3d02b8e2df2300a11ffa77f37b0ebd3ee07651bf06a13df6c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 148cfa51a0c173f52d7753e377b334b90fe1dabd115fc1c3c0c68fdc21911b901b85fb850c9dd68b11c9ec470b641b5d86e6f78f1c4c864ab0a919d12c547154
|
7
|
+
data.tar.gz: ca5934d04808afbb4282adff3951d4b7cedac89f7d61b7371c6d69a1854621a5506b0440b371c78624a3bffcac2baebf93473c5dc505998a3607c095f2111011
|
@@ -6,13 +6,20 @@ module AutoIncludeJson
|
|
6
6
|
Rails.logger.debug "AutoIncludeJson - Building includes from: #{include_option.inspect} from #{caller_locations(1,1).first.label}"
|
7
7
|
case include_option
|
8
8
|
when Array
|
9
|
-
include_option
|
9
|
+
include_option.map { |item| build_includes(item) }
|
10
10
|
when Hash
|
11
11
|
include_option.each_with_object({}) do |(assoc, value), hash|
|
12
|
+
# Skip keys that aren't associations
|
13
|
+
next if [:only, :except, :methods].include?(assoc)
|
14
|
+
|
12
15
|
if value.is_a?(Hash) && value[:include]
|
13
16
|
hash[assoc] = build_includes(value[:include])
|
17
|
+
elsif value.is_a?(Hash)
|
18
|
+
# If value is a hash, assume it might contain nested structure
|
19
|
+
nested = value.reject { |k, _| [:only, :except, :methods].include?(k) }
|
20
|
+
hash[assoc] = build_includes(nested) unless nested.empty?
|
14
21
|
else
|
15
|
-
hash[assoc] = {}
|
22
|
+
hash[assoc] = {} # eager load shallow association
|
16
23
|
end
|
17
24
|
end
|
18
25
|
else
|
@@ -11,7 +11,14 @@ module ApiExceptionManagement
|
|
11
11
|
rescue_from ActiveRecord::RecordInvalid, with: :invalid!
|
12
12
|
rescue_from ActiveRecord::RecordNotFound, with: :not_found!
|
13
13
|
rescue_from ActiveRecord::RecordNotUnique, with: :invalid!
|
14
|
+
# Rescue Stale Object in Optimistick locking with stale!
|
15
|
+
rescue_from ActiveRecord::StaleObjectError, with: :stale!
|
14
16
|
rescue_from EndpointValidationError, with: :api_error
|
17
|
+
rescue_from StandardError, with: :fivehundred!
|
18
|
+
end
|
19
|
+
|
20
|
+
def stale! exception = StandardError.new
|
21
|
+
return api_error status: 409, errors: exception.message
|
15
22
|
end
|
16
23
|
|
17
24
|
def unauthenticated! exception = AuthenticateUser::AccessDenied.new
|