belt 0.5.0 → 0.5.1

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: 5247752ecef8dc1c7241d3098a0896005f1533b2e1315914bf58c7534fa315f6
4
- data.tar.gz: 429bb361f14e70fd06988c6f0b026988e6623467ded6b8a3b7ee27849f607452
3
+ metadata.gz: 78ab45dc8e21870d427c1c8db110678daaaa1af5fc0b21501058111e8f6fa77e
4
+ data.tar.gz: f56e7412f04395c43cf521fc955a90956f89d738fe346102f02fc39eb3d1a7db
5
5
  SHA512:
6
- metadata.gz: da12badab39e69547f46b13c833c59a2a61902e62ba9a0442804586aaff9e7c8fe87bca9af9ffa970ea2e0ed68d0b9cc03b1721b71092661ec7d60fede9cb58f
7
- data.tar.gz: 13984899af7ad0f1b0e2badb0cc244a084ad75856601b0bde24b4a03eedab642dfbb8d03016392b8d941733861f5c3bb9de79ebab7e0ba17c74dca42c96ba1b8
6
+ metadata.gz: 6a6383f82c559b3880df9f0f70e2e7b5cffe308547881bb866397193f7d3e9570770f4e7246871b3761903925ba04a7ba91aefcc836407472df0289e51309fb8
7
+ data.tar.gz: 4019aff2e5064a6eec27d2a31f2f92ba4e0bc3222bc636f8df38e9d9579d703ff0c097d9f8725ff6577d536917a347c64d7d6e2261e0fbf0d1b6eea3c28bff21
@@ -28,8 +28,18 @@ module Belt
28
28
  end
29
29
 
30
30
  # JSON success. Status accepts Integer or Symbol (:created, :ok, …).
31
+ #
32
+ # The body is deep-serialized the same way implicit assigns are, so handing
33
+ # it a model (or a hash/array containing models) produces real JSON instead
34
+ # of the model's #to_s. This keeps `success_response(thing: @thing)` and the
35
+ # implicit `@thing = ...` path consistent — without it, an explicit
36
+ # success_response silently falls through to `JSON.generate` on the bare
37
+ # object and emits "#<Thing:0x...>". Falls back to the raw body when the
38
+ # serializer isn't mixed in (e.g. the lambda handler, which only ever passes
39
+ # plain hashes).
31
40
  def success_response(body, status_code = 200)
32
- { statusCode: resolve_status(status_code), headers: cors_headers, body: JSON.generate(body) }
41
+ serialized = respond_to?(:serialize_for_response, true) ? serialize_for_response(body) : body
42
+ { statusCode: resolve_status(status_code), headers: cors_headers, body: JSON.generate(serialized) }
33
43
  end
34
44
 
35
45
  # JSON error. Status accepts Integer or Symbol (:unprocessable_entity, :not_found, …).
data/lib/belt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Belt
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla